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

Function read_opt_string

src/models/wal.rs:84–97  ·  view source on GitHub ↗
(
    bufman: &FilelessBufferManager,
    cursor: u64,
)

Source from the content-addressed store, hash-verified

82}
83
84pub fn read_opt_string(
85 bufman: &FilelessBufferManager,
86 cursor: u64,
87) -> Result<Option<String>, BufIoError> {
88 let len = read_len(bufman, cursor)? as usize;
89 if len == 0 {
90 return Ok(None);
91 }
92 let mut buf = vec![0; len];
93 bufman.read_with_cursor(cursor, &mut buf)?;
94 let str = String::from_utf8(buf)
95 .map_err(|err| BufIoError::Io(io::Error::new(io::ErrorKind::InvalidData, err)))?;
96 Ok(Some(str))
97}
98
99impl WALFile {
100 pub fn new() -> Result<Self, BufIoError> {

Callers 1

readMethod · 0.70

Calls 2

read_with_cursorMethod · 0.80
read_lenFunction · 0.70

Tested by

no test coverage detected