pub struct CollectiveDelta {
pub version: u32,
pub delta_id: String,
pub created_at: u64,
pub source_id: String,
pub patterns: Vec<DeltaPattern>,
pub mistakes: Vec<MistakeReport>,
}Expand description
A collective delta containing patterns and mistakes to share.
Deltas are the unit of exchange for collective intelligence. They can be compressed for efficient transmission and storage.
Fields§
§version: u32Schema version for forward compatibility.
delta_id: StringUnique identifier for this delta (blake3 hash of contents).
created_at: u64Unix timestamp when this delta was created.
source_id: StringSource codebase identifier (anonymised).
patterns: Vec<DeltaPattern>Patterns discovered in this delta.
mistakes: Vec<MistakeReport>Mistakes reported in this delta.
Implementations§
Source§impl CollectiveDelta
impl CollectiveDelta
Sourcepub fn add_pattern(&mut self, pattern: DeltaPattern)
pub fn add_pattern(&mut self, pattern: DeltaPattern)
Add a pattern to the delta.
Sourcepub fn add_mistake(&mut self, mistake: MistakeReport)
pub fn add_mistake(&mut self, mistake: MistakeReport)
Add a mistake report to the delta.
Sourcepub fn finalize(&mut self) -> AcbResult<()>
pub fn finalize(&mut self) -> AcbResult<()>
Compute and set the delta ID based on content hash.
Sourcepub fn compress(&self) -> AcbResult<Vec<u8>>
pub fn compress(&self) -> AcbResult<Vec<u8>>
Compress the delta to a byte vector using lz4.
Serialises to JSON and then compresses with lz4_flex.
Sourcepub fn decompress(data: &[u8]) -> AcbResult<Self>
pub fn decompress(data: &[u8]) -> AcbResult<Self>
Decompress a delta from a compressed byte vector.
Decompresses with lz4_flex and deserialises from JSON.
Trait Implementations§
Source§impl Clone for CollectiveDelta
impl Clone for CollectiveDelta
Source§fn clone(&self) -> CollectiveDelta
fn clone(&self) -> CollectiveDelta
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CollectiveDelta
impl Debug for CollectiveDelta
Source§impl<'de> Deserialize<'de> for CollectiveDelta
impl<'de> Deserialize<'de> for CollectiveDelta
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for CollectiveDelta
impl RefUnwindSafe for CollectiveDelta
impl Send for CollectiveDelta
impl Sync for CollectiveDelta
impl Unpin for CollectiveDelta
impl UnsafeUnpin for CollectiveDelta
impl UnwindSafe for CollectiveDelta
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more