Trait novax_data::ManagedConvertible
source · pub trait ManagedConvertible<M: TopEncodeMulti> {
// Required method
fn to_managed(&self) -> M;
}Expand description
Provides a bridge from common Rust types to complex smart contract types managed by the MultiversX virtual machine.
This trait facilitates the conversion from native Rust types to managed types.
Unlike NativeConvertible, this bridge establishes a many-to-many relationship,
allowing multiple Rust types to be converted to multiple managed types.
Implementing this trait requires specifying the managed type parameter M and
providing an implementation for the to_managed method, which will carry out
the actual conversion.
Type Parameters
M: The managed type to which the native Rust type will be converted, constrained by theTopEncodeMultitrait.
Methods
to_managed: Performs the conversion from the native Rust type to the specified managed type.
Examples
Stringcan be converted toManagedBuffer,TokenIdentifier, orManagedAddress.Veccan be converted toManagedVec.
struct YourStruct(String);
impl ManagedConvertible<ManagedBuffer<StaticApi>> for YourStruct {
fn to_managed(&self) -> ManagedBuffer<StaticApi> {
ManagedBuffer::from(&*self.0)
}
}Required Methods§
sourcefn to_managed(&self) -> M
fn to_managed(&self) -> M
Converts the native Rust type to the specified managed type.