[][src]Trait amplify::Wrapper

pub trait Wrapper {
    type Inner: Clone;
    pub fn from_inner(inner: Self::Inner) -> Self;
pub fn as_inner(&self) -> &Self::Inner;
pub fn as_inner_mut(&mut self) -> &mut Self::Inner;
pub fn into_inner(self) -> Self::Inner; pub fn to_inner(&self) -> Self::Inner { ... } }

Trait defining wrapped types ("newtypes" in rust terminology). Wrapped types are used for allowing implemeting foreign traits to foreign types: https://doc.rust-lang.org/stable/rust-by-example/generics/new_types.html

Trait defines convenient methods for accessing inner data, construct and deconstruct newtype. It also serves as a marker trait for newtypes.

The trait works well with #[derive(Wrapper)] from amplify_derive crate

Associated Types

type Inner: Clone[src]

Inner type wrapped by the current newtype

Loading content...

Required methods

pub fn from_inner(inner: Self::Inner) -> Self[src]

Instantiates wrapper type with the inner data

pub fn as_inner(&self) -> &Self::Inner[src]

Returns reference to the inner representation for the wrapper type

pub fn as_inner_mut(&mut self) -> &mut Self::Inner[src]

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

pub fn into_inner(self) -> Self::Inner[src]

Unwraps the wrapper returning the inner type

Loading content...

Provided methods

pub fn to_inner(&self) -> Self::Inner[src]

Clones inner data of the wrapped type and return them

Loading content...

Implementors

impl Wrapper for IoError[src]

type Inner = ErrorKind

Loading content...