pub struct Hash(/* private fields */);ternary_hashes only.Expand description
Ternary cryptographic hash.
Implementations§
Methods from Deref<Target = Trits<T1B1>>§
Sourcepub fn is_empty(&self) -> bool
Available on crate feature ternary_encoding only.
pub fn is_empty(&self) -> bool
ternary_encoding only.Returns true if the trit slice is empty.
Sourcepub fn len(&self) -> usize
Available on crate feature ternary_encoding only.
pub fn len(&self) -> usize
ternary_encoding only.Returns the number of trits in this trit slice.
Sourcepub fn as_i8_slice(&self) -> &[i8]
Available on crate feature ternary_encoding only.
pub fn as_i8_slice(&self) -> &[i8]
ternary_encoding only.Interpret this slice as an (core::i8) slice.
§Panics
This function will panic if the slice is not byte-aligned.
Sourcepub unsafe fn as_i8_slice_mut(&mut self) -> &mut [i8]
Available on crate feature ternary_encoding only.
pub unsafe fn as_i8_slice_mut(&mut self) -> &mut [i8]
ternary_encoding only.Sourcepub unsafe fn get_unchecked(&self, index: usize) -> T::Trit
Available on crate feature ternary_encoding only.
pub unsafe fn get_unchecked(&self, index: usize) -> T::Trit
ternary_encoding only.Fetch the trit at the given index of this trit slice without first checking whether the index is in bounds. Providing an index that is not less than the length of this slice is undefined behaviour.
This is perhaps the ‘least bad’ unsafe function in this crate: not because any form of
undefined behaviour is better or worse than another (after all, the point of undefined
behaviour is that it is undefined) but because it’s the easiest to use correctly.
§Safety
An index with a value less then the result of Trits::len must be used. Any other value
is undefined behaviour.
Sourcepub unsafe fn set_unchecked(&mut self, index: usize, trit: T::Trit)
Available on crate feature ternary_encoding only.
pub unsafe fn set_unchecked(&mut self, index: usize, trit: T::Trit)
ternary_encoding only.Set the trit at the given index of this trit slice without first checking whether the index is in bounds. Providing an index that is not less than the length of this slice is undefined behaviour.
This is perhaps the ‘least bad’ unsafe function in this crate: not because any form of
undefined behaviour is better or worse than another (after all, the point of undefined
behaviour is that it is undefined) but because it’s the easiest to use correctly.
§Safety
An index with a value less then the result of Trits::len must be used. Any other value
is undefined behaviour.
Sourcepub fn get(&self, index: usize) -> Option<T::Trit>
Available on crate feature ternary_encoding only.
pub fn get(&self, index: usize) -> Option<T::Trit>
ternary_encoding only.Fetch the trit at the given index of this trit slice, if the index is valid.
Sourcepub fn set(&mut self, index: usize, trit: T::Trit)
Available on crate feature ternary_encoding only.
pub fn set(&mut self, index: usize, trit: T::Trit)
ternary_encoding only.Set the trit at the given index of this mutable trit slice, if the index is valid.
§Panics
This function will panic if the index is not less than the length of this slice.
Sourcepub fn iter(
&self,
) -> impl DoubleEndedIterator<Item = T::Trit> + ExactSizeIterator<Item = T::Trit> + '_
Available on crate feature ternary_encoding only.
pub fn iter( &self, ) -> impl DoubleEndedIterator<Item = T::Trit> + ExactSizeIterator<Item = T::Trit> + '_
ternary_encoding only.Returns an iterator over the trits in this slice.
Using this function is significantly faster than calling Trits::get in a loop and
should be used where possible.
Sourcepub fn subslice(&self, range: Range<usize>) -> &Self
Available on crate feature ternary_encoding only.
pub fn subslice(&self, range: Range<usize>) -> &Self
ternary_encoding only.Returns a subslice of this slice with the given range of trits.
§Panics
This function will panic if called with a range that contains indices outside this slice, or the start of the range is greater than its end.
Sourcepub fn subslice_mut(&mut self, range: Range<usize>) -> &mut Self
Available on crate feature ternary_encoding only.
pub fn subslice_mut(&mut self, range: Range<usize>) -> &mut Self
ternary_encoding only.Returns a mutable subslice of this mutable slice with the given range of trits.
§Panics
This function will panic if called with a range that contains indices outside this slice, or the start of the range is greater than its end.
Sourcepub fn copy_from<U: RawEncoding<Trit = T::Trit> + ?Sized>(
&mut self,
trits: &Trits<U>,
)
Available on crate feature ternary_encoding only.
pub fn copy_from<U: RawEncoding<Trit = T::Trit> + ?Sized>( &mut self, trits: &Trits<U>, )
ternary_encoding only.Copy the trits from a trit slice into this mutable trit slice (the encoding need not be equivalent).
§Panics
This function will panic if the length of the slices are different.
Sourcepub fn fill(&mut self, trit: T::Trit)
Available on crate feature ternary_encoding only.
pub fn fill(&mut self, trit: T::Trit)
ternary_encoding only.Fill this mutable trit slice with copied of the given trit.
Sourcepub fn to_buf<U: RawEncodingBuf<Slice = T>>(&self) -> TritBuf<U>
Available on crate feature ternary_encoding only.
pub fn to_buf<U: RawEncodingBuf<Slice = T>>(&self) -> TritBuf<U>
ternary_encoding only.Copy the contents of this trit slice into a new TritBuf with the same encoding. This
function is analogous to to_vec method implemented on ordinary slices.
Sourcepub fn chunks(
&self,
chunk_len: usize,
) -> impl DoubleEndedIterator<Item = &Self> + ExactSizeIterator<Item = &Self> + '_
Available on crate feature ternary_encoding only.
pub fn chunks( &self, chunk_len: usize, ) -> impl DoubleEndedIterator<Item = &Self> + ExactSizeIterator<Item = &Self> + '_
ternary_encoding only.Return an iterator over distinct, non-overlapping subslices of this trit slice, each with the given chunk length. If the length of the trit slice is not a multiple of the given chunk length, the last slice provided by the iterator will be smaller to compensate.
§Panics
This function will panic if the given chunk length is 0.
Sourcepub fn encode<U>(&self) -> TritBuf<U>
Available on crate feature ternary_encoding only.
pub fn encode<U>(&self) -> TritBuf<U>
ternary_encoding only.Encode the contents of this trit slice into a TritBuf with a different encoding.
Sourcepub fn iter_trytes(
&self,
) -> impl DoubleEndedIterator<Item = Tryte> + ExactSizeIterator<Item = Tryte> + '_
Available on crate feature ternary_encoding only.
pub fn iter_trytes( &self, ) -> impl DoubleEndedIterator<Item = Tryte> + ExactSizeIterator<Item = Tryte> + '_
ternary_encoding only.Returns an iterator over the trytes represented within this slice.
For encodings that are representation-compatible with trytes, such as T3B1, use
Trits::as_trytes instead since it is faster and more capable.
Sourcepub fn negate(&mut self)
Available on crate feature ternary_encoding only.
pub fn negate(&mut self)
ternary_encoding only.Negate each trit in this buffer.
This has the effect of making the trit buffer negative when expressed in numeric form.
Sourcepub fn as_raw_slice(&self) -> &[T]
Available on crate feature ternary_encoding only.
pub fn as_raw_slice(&self) -> &[T]
ternary_encoding only.View this trit slice as an ordinary slice of trits.
Sourcepub fn as_raw_slice_mut(&mut self) -> &mut [T]
Available on crate feature ternary_encoding only.
pub fn as_raw_slice_mut(&mut self) -> &mut [T]
ternary_encoding only.View this mutable trit slice as an ordinary slice of mutable trits.
Sourcepub fn chunks_mut(
&mut self,
chunk_len: usize,
) -> impl Iterator<Item = &mut Self> + '_
Available on crate feature ternary_encoding only.
pub fn chunks_mut( &mut self, chunk_len: usize, ) -> impl Iterator<Item = &mut Self> + '_
ternary_encoding only.Return an iterator over distinct, non-overlapping mutable subslices of this mutable trit slice, each with the given chunk length. If the length of the trit slice is not a multiple of the given chunk length, the last slice provided by the iterator will be smaller to compensate.
§Panics
This function will panic if the given chunk length is 0.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, T>
Available on crate feature ternary_encoding only.
pub fn iter_mut(&mut self) -> IterMut<'_, T>
ternary_encoding only.Returns a mutable iterator over the trits in this slice.
Using this function is significantly faster than calling Trits::set in a loop and
should be used where possible.