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

Method deserialize

src/models/versioning.rs:122–158  ·  view source on GitHub ↗
(bytes: &[u8])

Source from the content-addressed store, hash-verified

120 }
121
122 fn deserialize(bytes: &[u8]) -> Result<Self, &'static str> {
123 if bytes.len() != 29 {
124 return Err("Input must be exactly 29 bytes");
125 }
126
127 let version = u32::from_le_bytes(bytes[0..4].try_into().unwrap());
128 let explicit = bytes[4] == 0;
129
130 let source = if explicit {
131 VersionSource::Explicit {
132 transaction_id: ExplicitTransactionID::from(u32::from_le_bytes(
133 bytes[5..9].try_into().unwrap(),
134 )),
135 }
136 } else {
137 VersionSource::Implicit {
138 epoch_id: u32::from_le_bytes(bytes[5..9].try_into().unwrap()),
139 }
140 };
141
142 let created_at_timestamp = i64::from_le_bytes(bytes[9..17].try_into().unwrap());
143 let created_at =
144 DateTime::from_timestamp(created_at_timestamp, 0).ok_or("Invalid Timestamp")?;
145
146 let records_upserted = u32::from_le_bytes(bytes[17..21].try_into().unwrap());
147 let records_deleted = u32::from_le_bytes(bytes[21..25].try_into().unwrap());
148 let total_operations = u32::from_le_bytes(bytes[25..29].try_into().unwrap());
149
150 Ok(VersionInfo {
151 version: VersionNumber(version),
152 source,
153 created_at,
154 records_upserted,
155 records_deleted,
156 total_operations,
157 })
158 }
159}
160
161pub struct VersionControl {

Callers

nothing calls this directly

Calls 2

VersionNumberClass · 0.85
lenMethod · 0.45

Tested by

no test coverage detected