MCPcopy Create free account
hub / github.com/cosdata/cosdata / read_opt_string

Function read_opt_string

src/models/serializer/mod.rs:68–78  ·  view source on GitHub ↗
(bufman: &BufferManager, cursor: u64)

Source from the content-addressed store, hash-verified

66}
67
68pub fn read_opt_string(bufman: &BufferManager, cursor: u64) -> Result<Option<String>, BufIoError> {
69 let len = read_len(bufman, cursor)? as usize;
70 if len == 0 {
71 return Ok(None);
72 }
73 let mut buf = vec![0; len];
74 bufman.read_with_cursor(cursor, &mut buf)?;
75 let str = String::from_utf8(buf)
76 .map_err(|err| BufIoError::Io(io::Error::new(io::ErrorKind::InvalidData, err)))?;
77 Ok(Some(str))
78}
79
80pub trait SimpleSerialize: Sized {
81 fn serialize(&self, bufman: &BufferManager, cursor: u64) -> Result<u32, BufIoError>;

Callers 1

deserializeMethod · 0.70

Calls 2

read_with_cursorMethod · 0.80
read_lenFunction · 0.70

Tested by

no test coverage detected