MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / encode_bitemporal

Method encode_bitemporal

nodedb-strict/src/encode.rs:172–198  ·  view source on GitHub ↗

Encode a row for a bitemporal strict schema. The three reserved slots (0/1/2) are populated from the provided timestamps; the remaining slots are filled from `user_values` in schema order. Errors if the schema is not bitemporal or if `user_values.len() != schema.len() - 3`.

(
        &self,
        system_from_ms: i64,
        valid_from_ms: i64,
        valid_until_ms: i64,
        user_values: &[Value],
    )

Source from the content-addressed store, hash-verified

170 /// Errors if the schema is not bitemporal or if `user_values.len() !=
171 /// schema.len() - 3`.
172 pub fn encode_bitemporal(
173 &self,
174 system_from_ms: i64,
175 valid_from_ms: i64,
176 valid_until_ms: i64,
177 user_values: &[Value],
178 ) -> Result<Vec<u8>, StrictError> {
179 if !self.schema.bitemporal {
180 return Err(StrictError::ValueCountMismatch {
181 expected: self.schema.columns.len(),
182 got: user_values.len() + 3,
183 });
184 }
185 let expected_user = self.schema.columns.len().saturating_sub(3);
186 if user_values.len() != expected_user {
187 return Err(StrictError::ValueCountMismatch {
188 expected: expected_user,
189 got: user_values.len(),
190 });
191 }
192 let mut all = Vec::with_capacity(self.schema.columns.len());
193 all.push(Value::Integer(system_from_ms));
194 all.push(Value::Integer(valid_from_ms));
195 all.push(Value::Integer(valid_until_ms));
196 all.extend_from_slice(user_values);
197 self.encode(&all)
198 }
199}
200
201/// Encode a fixed-size value into the buffer at the given position.

Calls 3

lenMethod · 0.45
pushMethod · 0.45
encodeMethod · 0.45