pub struct ChunkCorrection {
pub chunk_id: u64,
pub correction: CorrectionType,
pub hash: [u8; 8],
pub parity: Trit,
}Expand description
A correction record for a data chunk
Fields§
§chunk_id: u64Chunk identifier
correction: CorrectionTypeType of correction needed
hash: [u8; 8]Verification hash (first 8 bytes of SHA256)
parity: TritParity trit for the chunk
Implementations§
Source§impl ChunkCorrection
impl ChunkCorrection
Sourcepub fn new(chunk_id: u64, original: &[u8], approximation: &[u8]) -> Self
pub fn new(chunk_id: u64, original: &[u8], approximation: &[u8]) -> Self
Create a correction record
Sourcepub fn needs_correction(&self) -> bool
pub fn needs_correction(&self) -> bool
Check if correction is needed
Sourcepub fn apply(&self, approximation: &[u8]) -> Vec<u8> ⓘ
pub fn apply(&self, approximation: &[u8]) -> Vec<u8> ⓘ
Apply correction to approximation to get original
Sourcepub fn storage_size(&self) -> usize
pub fn storage_size(&self) -> usize
Storage size of this correction
Trait Implementations§
Source§impl Clone for ChunkCorrection
impl Clone for ChunkCorrection
Source§fn clone(&self) -> ChunkCorrection
fn clone(&self) -> ChunkCorrection
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 ChunkCorrection
impl Debug for ChunkCorrection
Source§impl<'de> Deserialize<'de> for ChunkCorrection
impl<'de> Deserialize<'de> for ChunkCorrection
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 ChunkCorrection
impl RefUnwindSafe for ChunkCorrection
impl Send for ChunkCorrection
impl Sync for ChunkCorrection
impl Unpin for ChunkCorrection
impl UnwindSafe for ChunkCorrection
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