MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / write_string

Method write_string

crates/table/src/bflatn_to.rs:327–339  ·  view source on GitHub ↗

Write the string `str` to the var-len section and a `VarLenRef` to the fixed buffer and advance the `curr_offset`.

(&mut self, val: &str)

Source from the content-addressed store, hash-verified

325 /// Write the string `str` to the var-len section
326 /// and a `VarLenRef` to the fixed buffer and advance the `curr_offset`.
327 fn write_string(&mut self, val: &str) -> Result<(), Error> {
328 let val = val.as_bytes();
329
330 // Write `val` to the page. The handle is `vlr`.
331 let (vlr, in_blob) = self.var_view.alloc_for_slice(val)?;
332 if in_blob {
333 self.defer_insert_large_blob(vlr, val.to_vec());
334 }
335
336 // Write `vlr` to the fixed part.
337 self.write_var_len_ref(vlr);
338 Ok(())
339 }
340
341 /// Write `val` BSATN-encoded to var-len section
342 /// and a `VarLenRef` to the fixed buffer and advance the `curr_offset`.

Callers 1

write_valueMethod · 0.45

Calls 6

alloc_for_sliceMethod · 0.80
to_vecMethod · 0.80
write_var_len_refMethod · 0.80
OkFunction · 0.50
as_bytesMethod · 0.45

Tested by

no test coverage detected