Struct amplify::Slice32

source ·
pub struct Slice32(_);
Expand description

Wrapper type for all slice-based 256-bit types implementing many important traits, so types based on it can simply derive their implementations.

Type keeps data in little-endian byte order and displays them in the same order (like bitcoin SHA256 single hash type).

Implementations§

source§

impl Slice32

source

pub fn from_slice(slice: impl AsRef<[u8]>) -> Option<Slice32>

Constructs 256-bit array from a provided slice. If the slice length is not equal to 32 bytes, returns None

source

pub fn as_slice(&self) -> &[u8]

Returns byte slice representation.

source

pub fn as_slice_mut(&mut self) -> &mut [u8]

Returns mutable byte slice representation.

source

pub fn to_vec(&self) -> Vec<u8>

Returns vector representing internal slice data

Trait Implementations§

source§

impl AsMut<[u8]> for Slice32

source§

fn as_mut(&mut self) -> &mut [u8]

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsRef<[u8]> for Slice32

source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Borrow<[u8]> for Slice32

source§

fn borrow(&self) -> &[u8]

Immutably borrows from an owned value. Read more
source§

impl BorrowMut<[u8]> for Slice32

source§

fn borrow_mut(&mut self) -> &mut [u8]

Mutably borrows from an owned value. Read more
source§

impl Clone for Slice32

source§

fn clone(&self) -> Slice32

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Slice32

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Slice32

source§

fn default() -> Slice32

Returns the “default value” for a type. Read more
source§

impl Display for Slice32

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T> From<T> for Slice32where
T: Into<[u8; 32]>,

source§

fn from(array: T) -> Self

Converts to this type from the input type.
source§

impl FromHex for Slice32

source§

fn from_byte_iter<I>(iter: I) -> Result<Self, Error>where
I: Iterator<Item = Result<u8, Error>> + ExactSizeIterator + DoubleEndedIterator,

Produce an object from a byte iterator
source§

fn from_hex(s: &str) -> Result<Self, Error>

Produce an object from a hex string
source§

impl FromStr for Slice32

§

type Err = Error

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for Slice32

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where
H: Hasher,
Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Index<RangeFull> for Slice32

§

type Output = [u8]

The returned type after indexing.
source§

fn index(&self, index: RangeFull) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl Index<u8> for Slice32

§

type Output = u8

The returned type after indexing.
source§

fn index(&self, index: u8) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl Index<usize> for Slice32

§

type Output = u8

The returned type after indexing.
source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl IndexMut<u8> for Slice32

source§

fn index_mut(&mut self, index: u8) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

impl IndexMut<usize> for Slice32

source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

impl LowerHex for Slice32

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter.
source§

impl Ord for Slice32

source§

fn cmp(&self, other: &Slice32) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere
Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere
Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<Slice32> for Slice32

source§

fn eq(&self, other: &Slice32) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Slice32> for Slice32

source§

fn partial_cmp(&self, other: &Slice32) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl UpperHex for Slice32

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter.
source§

impl Wrapper for Slice32

§

type Inner = [u8; 32]

Inner type wrapped by the current newtype
source§

fn from_inner(inner: Self::Inner) -> Self

Instantiates wrapper type with the inner data
source§

fn as_inner(&self) -> &Self::Inner

Returns reference to the inner representation for the wrapper type
source§

fn as_inner_mut(&mut self) -> &mut Self::Inner

Returns a mutable reference to the inner representation for the wrapper type
source§

fn into_inner(self) -> Self::Inner

Unwraps the wrapper returning the inner type
source§

fn to_inner(&self) -> Self::Inner

Clones inner data of the wrapped type and return them
source§

impl Copy for Slice32

source§

impl Eq for Slice32

source§

impl StructuralEq for Slice32

source§

impl StructuralPartialEq for Slice32

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere
T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere
U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToHex for Twhere
T: LowerHex,

source§

fn to_hex(&self) -> String

Outputs the hash in hexadecimal form

source§

impl<T> ToOwned for Twhere
T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere
T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere
U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.