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

Method encode

crates/commitlog/src/payload/txdata.rs:121–137  ·  view source on GitHub ↗
(&self, buf: &mut impl BufWriter)

Source from the content-addressed store, hash-verified

119 pub const VERSION: u8 = DEFAULT_LOG_FORMAT_VERSION;
120
121 pub fn encode(&self, buf: &mut impl BufWriter) {
122 let mut flags = Flags::empty();
123 flags.set(Flags::HAVE_INPUTS, self.inputs.is_some());
124 flags.set(Flags::HAVE_OUTPUTS, self.outputs.is_some());
125 flags.set(Flags::HAVE_MUTATIONS, self.mutations.is_some());
126
127 buf.put_u8(flags.bits());
128 if let Some(inputs) = &self.inputs {
129 inputs.encode(buf);
130 }
131 if let Some(outputs) = &self.outputs {
132 outputs.encode(buf);
133 }
134 if let Some(mutations) = &self.mutations {
135 mutations.encode(buf)
136 }
137 }
138
139 /// Decode `Self` from the given buffer.
140 pub fn decode<'a, V, R>(visitor: &mut V, reader: &mut R) -> Result<Self, V::Error>

Callers 1

encode_recordMethod · 0.45

Calls 10

encode_varintFunction · 0.85
put_u8Method · 0.80
put_u32Method · 0.80
iterMethod · 0.65
emptyFunction · 0.50
setMethod · 0.45
bitsMethod · 0.45
lenMethod · 0.45
put_sliceMethod · 0.45
as_bytesMethod · 0.45

Tested by

no test coverage detected