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
This is useful when calling associated methods on a move type that don’t depend on the specific type argument.
§Examples
use af_move_type::{MoveStruct, MoveType, otw::Otw};
use serde::{Deserialize, Serialize};
#[derive(MoveStruct, Clone, Debug, Default, Deserialize, Serialize, PartialEq, Eq, Hash)]
#[move_(address = "0x2", module = balance)]
pub struct Balance<T: MoveType> {
value: u64,
_otw: std::marker::PhantomData<T>,
}
// for compilation purposes
impl<T: MoveType> std::fmt::Display for Balance<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
todo!()
}
}
let address = "0x2".parse().unwrap();
let module = "sui".parse().unwrap();
let name = "SUI".parse().unwrap();
let otw = Otw::type_(address, module, name);
let usdc_type = Balance::<Otw>::type_(otw);Implementations§
Source§impl Otw
impl Otw
pub fn move_instance( self, address: Address, module: Identifier, name: Identifier, ) -> MoveInstance<Self>
pub fn type_( address: Address, module: Identifier, name: Identifier, ) -> OtwTypeTag
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Otw
impl<'de> Deserialize<'de> for Otw
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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 MoveStruct for Otw
impl MoveStruct for Otw
type StructTag = OtwTypeTag
Source§impl MoveType for Otw
impl MoveType for Otw
Source§impl StaticTypeParams for Otw
impl StaticTypeParams for Otw
fn type_params() -> Vec<TypeTag>
impl Eq for Otw
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<'de, T> FromBcs for Twhere
T: Deserialize<'de>,
impl<'de, T> FromBcs for Twhere
T: Deserialize<'de>,
fn from_bcs<'de>(bytes: &'de [u8]) -> Result<Self, Error>where
Self: Deserialize<'de>,
fn from_bcs_base64(base64: &str) -> Result<Self, Error>where
Self: DeserializeOwned,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more