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

Method serialize

src/models/versioning.rs:98–120  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

96 }
97
98 fn serialize(&self) -> Vec<u8> {
99 let mut result = Vec::with_capacity(29);
100
101 result.extend_from_slice(&self.version.to_le_bytes());
102 match self.source {
103 VersionSource::Explicit { transaction_id } => {
104 result.push(0);
105 result.extend_from_slice(&transaction_id.to_le_bytes());
106 }
107 VersionSource::Implicit { epoch_id } => {
108 result.push(1);
109 result.extend_from_slice(&epoch_id.to_le_bytes());
110 }
111 }
112
113 result.extend_from_slice(&self.created_at.timestamp().to_le_bytes());
114
115 result.extend_from_slice(&self.records_upserted.to_le_bytes());
116 result.extend_from_slice(&self.records_deleted.to_le_bytes());
117 result.extend_from_slice(&self.total_operations.to_le_bytes());
118
119 result
120 }
121
122 fn deserialize(bytes: &[u8]) -> Result<Self, &'static str> {
123 if bytes.len() != 29 {

Callers 4

newMethod · 0.45

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected