[−][src]Struct bct::Tryte
Methods
impl Tryte
[src]
pub fn from_bct_trybbles(hi: u8, lo: u8) -> Self
[src]
Convert two BCT trybbles (3-trit numbers) to a Tryte (6 trits)
let hi = 0b_00_01_10; // 01T let lo = 0b_10_00_01; // T01 let tryte = Tryte::from_bct_trybbles(hi, lo); assert_eq!(tryte.to_integer(), 46);
pub fn hi_value(&self) -> i8
[src]
Returns a value of the Tryte's high trybble (high 3 trits)
let tryte = Tryte::from(46); // 01TT01 assert_eq!(tryte.hi_value(), 2); // 01T => 2
pub fn lo_value(&self) -> i8
[src]
Returns a value of the Tryte's low trybble (low 3 trits)
let tryte = Tryte::from(46); // 01TT01 assert_eq!(tryte.lo_value(), -8); // T01 => -8
pub fn hi_bct(&self) -> u8
[src]
Returns the BCT representation of the Tryte's high trybble (high 3 trits)
let tryte = Tryte::from(46); // 01TT01 assert_eq!(tryte.hi_bct(), 0b_00_01_10); // 01T
pub fn lo_bct(&self) -> u8
[src]
Returns the BCT representation of the Tryte's low trybble (low 3 trits)
let tryte = Tryte::from(46); // 01TT01 assert_eq!(tryte.lo_bct(), 0b_10_00_01); // T01
pub fn to_integer(&self) -> i16
[src]
Returns a value of the Tryte
let tryte = Tryte::from(46); // 01TT01 assert_eq!(tryte.to_integer(), 46);
pub fn as_ternary_string(&self) -> Option<String>
[src]
Returns ternary representation of a tryte
let tryte = Tryte::from(46); assert_eq!(tryte.as_ternary_string().unwrap(), "01TT01");
pub fn as_nonary_string(&self) -> Option<String>
[src]
Returns nonary representation of a tryte
let tryte = Tryte::from(46); assert_eq!(tryte.as_nonary_string().unwrap(), "1D1");
pub fn add(first: &Tryte, second: &Tryte) -> (Tryte, i8)
[src]
Adds two trytes together and returns the result and a carry
let first = Tryte::from(46); let second = Tryte::from(54); let (result, _) = Tryte::add(&first, &second); assert_eq!(result.to_integer(), 100);
pub fn sub(first: &Tryte, second: &Tryte) -> (Tryte, i8)
[src]
Subtracts second from first and returns the result and a carry
let first = Tryte::from(46); let second = Tryte::from(54); let (result, _) = Tryte::sub(&first, &second); assert_eq!(result.to_integer(), -8);
Trait Implementations
impl Clone for Tryte
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for Tryte
[src]
impl From<i16> for Tryte
[src]
impl Into<i16> for Tryte
[src]
Auto Trait Implementations
impl RefUnwindSafe for Tryte
impl Send for Tryte
impl Sync for Tryte
impl Unpin for Tryte
impl UnwindSafe for Tryte
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,