pub struct BalancedTernaryWord { /* private fields */ }Expand description
64-bit balanced ternary encoding unit
- 61 bits: data payload (39 trits worth of information)
- 3 bits: parity/metadata (2 trits)
Implementations§
Source§impl BalancedTernaryWord
impl BalancedTernaryWord
Sourcepub const MAX_VALUE: i64 = 675_425_858_836_496_044
pub const MAX_VALUE: i64 = 675_425_858_836_496_044
Maximum value representable in 38 trits (signed balanced) 3^38 = 1,350,851,717,672,992,089 (fits in 61 bits) Range: -(3^38-1)/2 to +(3^38-1)/2
pub const MIN_VALUE: i64 = -675_425_858_836_496_044
Sourcepub const DATA_TRITS: usize = 38
pub const DATA_TRITS: usize = 38
Number of trits in the data portion (38 trits = 61 bits)
Sourcepub const META_TRITS: usize = 2
pub const META_TRITS: usize = 2
Number of trits for metadata/parity (stored in upper 3 bits)
Sourcepub fn new(value: i64, metadata: WordMetadata) -> Result<Self, VsaError>
pub fn new(value: i64, metadata: WordMetadata) -> Result<Self, VsaError>
Create a new word from a signed integer value and metadata
Sourcepub fn metadata(&self) -> WordMetadata
pub fn metadata(&self) -> WordMetadata
Extract metadata
Sourcepub fn compute_parity(&self) -> i8
pub fn compute_parity(&self) -> i8
Compute parity trit for error detection
Trait Implementations§
Source§impl Clone for BalancedTernaryWord
impl Clone for BalancedTernaryWord
Source§fn clone(&self) -> BalancedTernaryWord
fn clone(&self) -> BalancedTernaryWord
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 BalancedTernaryWord
impl Debug for BalancedTernaryWord
Source§impl<'de> Deserialize<'de> for BalancedTernaryWord
impl<'de> Deserialize<'de> for BalancedTernaryWord
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
Source§impl Hash for BalancedTernaryWord
impl Hash for BalancedTernaryWord
Source§impl PartialEq for BalancedTernaryWord
impl PartialEq for BalancedTernaryWord
Source§impl Serialize for BalancedTernaryWord
impl Serialize for BalancedTernaryWord
impl Copy for BalancedTernaryWord
impl Eq for BalancedTernaryWord
impl StructuralPartialEq for BalancedTernaryWord
Auto Trait Implementations§
impl Freeze for BalancedTernaryWord
impl RefUnwindSafe for BalancedTernaryWord
impl Send for BalancedTernaryWord
impl Sync for BalancedTernaryWord
impl Unpin for BalancedTernaryWord
impl UnwindSafe for BalancedTernaryWord
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more