pub struct CodedSymbol<T: Symbol> {
pub sum: Vec<u8>,
pub hash: u64,
pub count: i64,
/* private fields */
}Expand description
A RIBLT is an infinite sequence of CodedSymbols
The ‘sum’ field is the XOR of the symbols encoded into this CodedSymbol
The ‘hash’ field is the XOR of the hashes of the symbols encoded into this CodedSymbol
The ‘count’ field is the number of local symbols minus the number of remote symbols
The ‘_marker’ phantom field is used to allow us to associate the CodedSymbol with a specific Symbol type. The type T is used by implemented methods to know what type of Symbol is encoded in the CodedSymbol.
A CodedSymbol can be peeled when the count is 1 or -1 and the hash matches
Fields§
§sum: Vec<u8>§hash: u64§count: i64Implementations§
Source§impl<T: Symbol> CodedSymbol<T>
impl<T: Symbol> CodedSymbol<T>
pub fn new() -> Self
Sourcepub fn apply(&mut self, s: &T, direction: Direction)
pub fn apply(&mut self, s: &T, direction: Direction)
apply() adds or removes a symbol from the CodedSymbol
Adding a local, or removing a remote, symbol increases the count by 1
Removing a local, or adding a remote, symbol decreases the count by 1
Sourcepub fn combine(&self, b: &CodedSymbol<T>) -> CodedSymbol<T>
pub fn combine(&self, b: &CodedSymbol<T>) -> CodedSymbol<T>
Used by the encoder to join two vectors of codedSymbols together produced from two distinct sets. The results are only valid if there were no duplicates between the original sets.
Sourcepub fn collapse(&self, b: &CodedSymbol<T>) -> CodedSymbol<T>
pub fn collapse(&self, b: &CodedSymbol<T>) -> CodedSymbol<T>
Used by the encoder to ‘subtract’ a remote set of codedSymbols from a local set.
Sourcepub fn is_peelable(&self) -> bool
pub fn is_peelable(&self) -> bool
Checks if the CodedSymbol contains only one symbol and therefore can be peeled
A count of 1 does not necessarily mean that the ‘sum’ field is the xor of only one encoded symbol. It could be the xor of two local and one remote symbols. This is why we also check the hash.
Trait Implementations§
Source§impl<T: Clone + Symbol> Clone for CodedSymbol<T>
impl<T: Clone + Symbol> Clone for CodedSymbol<T>
Source§fn clone(&self) -> CodedSymbol<T>
fn clone(&self) -> CodedSymbol<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more