Struct Otw

Source
pub struct Otw { /* private fields */ }
Expand description

Generic type signaling a one-time-witness type argument.

None of address, module and name are known at compile time, only that there are no type parameters.

Use this when you want to instantiate a datatype like Balance<phantom T> that expects its type argument to be a Move one-time-witness.

§Examples

use moverox::Otw;
use moverox::traits::{MoveDatatype, MoveType};
use serde::{Deserialize, Serialize};

#[derive(MoveDatatype, Clone, Debug, Default, Deserialize, Serialize, PartialEq, Eq, Hash)]
#[move_(address = "0x2", module = balance)]
pub struct Balance<T> {
    value: u64,
    _otw: std::marker::PhantomData<T>,
}

let address = "0x2".parse().unwrap();
let module = "sui".parse().unwrap();
let name = "SUI".parse().unwrap();
let sui_type = Otw::type_tag(address, module, name);
let balance_type = Balance::<Otw>::type_tag(sui_type);

Implementations§

Source§

impl Otw

Source

pub const fn type_tag( address: Address, module: Identifier, name: Identifier, ) -> OtwTypeTag

Create this type’s specialized type tag.

Source§

impl Otw

Source

pub const fn new() -> Self

Trait Implementations§

Source§

impl Clone for Otw

Source§

fn clone(&self) -> Otw

Returns a duplicate 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 Otw

Source§

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

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

impl Default for Otw

Source§

fn default() -> Otw

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

impl<'de> Deserialize<'de> for Otw

Source§

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 Otw

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 MoveDatatype for Otw

Source§

impl MoveType for Otw

Source§

impl PartialEq for Otw

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Otw

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Otw

Source§

impl StructuralPartialEq for Otw

Auto Trait Implementations§

§

impl Freeze for Otw

§

impl RefUnwindSafe for Otw

§

impl Send for Otw

§

impl Sync for Otw

§

impl Unpin for Otw

§

impl UnwindSafe for Otw

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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> ToOwned for T
where T: Clone,

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,