MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / until

Method until

src/pgtest/src/lib.rs:148–322  ·  view source on GitHub ↗
(
        &mut self,
        until: Vec<&str>,
        err_field_typs: Vec<char>,
        ignore: BTreeSet<String>,
    )

Source from the content-addressed store, hash-verified

146 Ok(())
147 }
148 fn until(
149 &mut self,
150 until: Vec<&str>,
151 err_field_typs: Vec<char>,
152 ignore: BTreeSet<String>,
153 ) -> anyhow::Result<Vec<String>> {
154 let mut msgs = Vec::with_capacity(until.len());
155 for expect in until {
156 loop {
157 let (ch, msg) = match self.recv() {
158 Ok((ch, msg)) => (ch, msg),
159 Err(err) => bail!("{}: waiting for {}, saw {:#?}", err, expect, msgs),
160 };
161 let (typ, args) = match msg {
162 Message::ReadyForQuery(body) => (
163 "ReadyForQuery",
164 serde_json::to_string(&ReadyForQuery {
165 status: char::from(body.status()).to_string(),
166 })?,
167 ),
168 Message::RowDescription(body) => (
169 "RowDescription",
170 serde_json::to_string(&RowDescription {
171 fields: body
172 .fields()
173 .map(|f| {
174 Ok(Field {
175 name: f.name().to_string(),
176 })
177 })
178 .collect()
179 .unwrap(),
180 })?,
181 ),
182 Message::DataRow(body) => {
183 let buf = body.buffer();
184 (
185 "DataRow",
186 serde_json::to_string(&DataRow {
187 fields: body
188 .ranges()
189 .map(|range| {
190 match range {
191 Some(range) => {
192 // Attempt to convert to a String. If not utf8, print as array of bytes instead.
193 Ok(String::from_utf8(
194 buf[range.start..range.end].to_vec(),
195 )
196 .unwrap_or_else(|_| {
197 format!(
198 "{:?}",
199 buf[range.start..range.end].to_vec()
200 )
201 }))
202 }
203 None => Ok("NULL".into()),
204 }
205 })

Callers 1

newMethod · 0.45

Calls 15

to_stringFunction · 0.85
unwrapMethod · 0.80
fieldsMethod · 0.80
to_vecMethod · 0.80
tagMethod · 0.80
type_Method · 0.80
dataMethod · 0.80
format_nameFunction · 0.70
lenMethod · 0.45
recvMethod · 0.45
to_stringMethod · 0.45
statusMethod · 0.45

Tested by

no test coverage detected