MCPcopy Create free account
hub / github.com/f0rr0/oliphaunt / cstring

Method cstring

src/protocol/buffer_reader.rs:51–66  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

49 }
50
51 pub fn cstring(&mut self) -> Result<String> {
52 let start = self.offset;
53 loop {
54 let next = self
55 .buffer
56 .get(self.offset)
57 .copied()
58 .ok_or_else(|| anyhow::anyhow!("unterminated cstring"))?;
59 self.offset += 1;
60 if next == 0 {
61 let slice = &self.buffer[start..self.offset - 1];
62 let text = std::str::from_utf8(slice)?;
63 return Ok(text.to_owned());
64 }
65 }
66 }
67
68 pub fn bytes(&mut self, length: usize) -> Result<Vec<u8>> {
69 let bytes = self.take_slice(length)?;

Callers 6

parse_notificationMethod · 0.80
parse_fieldMethod · 0.80
parse_authenticationMethod · 0.80
collect_fieldsFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected