pub struct MoveStruct { /* private fields */ }Expand description
A move struct
§BCS
The BCS serialized form for this type is defined by the following ABNF:
move-struct = compressed-struct-tag u64 bytes
compressed-struct-tag = other-struct-type / gas-coin-type / staked-iota-type / coin-type
other-struct-type = %d00 struct-tag
gas-coin-type = %d01
staked-iota-type = %d02
coin-type = %d03 type-tag
; The first 32 bytes of the `bytes` contents are the object's object-id.Implementations§
Source§impl MoveStruct
impl MoveStruct
Sourcepub fn new(
object_type: MoveObjectType,
version: Version,
contents: Vec<u8>,
) -> Result<Self, MoveStructContentsError>
pub fn new( object_type: MoveObjectType, version: Version, contents: Vec<u8>, ) -> Result<Self, MoveStructContentsError>
Creates a new MoveStruct.
§Errors
Returns an error if contents is shorter than ObjectId::LENGTH
bytes, since every Move object must contain its ObjectId as the
leading bytes.
Sourcepub fn object_type(&self) -> &MoveObjectType
pub fn object_type(&self) -> &MoveObjectType
Returns the type of this Move object.
Sourcepub fn struct_tag(&self) -> &StructTag
pub fn struct_tag(&self) -> &StructTag
Returns the object type as a StructTag reference.
Sourcepub fn is_struct_tag(&self, s: &StructTag) -> bool
pub fn is_struct_tag(&self, s: &StructTag) -> bool
Returns true if the object’s type matches the given StructTag.
Sourcepub fn id(&self) -> ObjectId
pub fn id(&self) -> ObjectId
Returns the object’s ID, extracted from the BCS-encoded contents.
This is always valid because the constructor guarantees that contents
is at least ObjectId::LENGTH bytes long.
Sourcepub fn set_version(&mut self, version: Version)
pub fn set_version(&mut self, version: Version)
Sets the version (lamport timestamp) of this object.
Sourcepub fn set_object_type(&mut self, object_type: MoveObjectType)
pub fn set_object_type(&mut self, object_type: MoveObjectType)
Sets the type of this object.
The caller must ensure the existing contents are a
valid BCS encoding of the new object_type; this is not verified.
Sourcepub fn set_contents(
&mut self,
contents: Vec<u8>,
) -> Result<(), MoveStructContentsError>
pub fn set_contents( &mut self, contents: Vec<u8>, ) -> Result<(), MoveStructContentsError>
Replaces the BCS-encoded contents of this object.
The caller must ensure the new contents are a valid BCS encoding of the
object’s object_type; this is not verified.
§Errors
Returns an error if contents is shorter than ObjectId::LENGTH
bytes.
Sourcepub fn into_contents(self) -> Vec<u8> ⓘ
pub fn into_contents(self) -> Vec<u8> ⓘ
Consumes the object and returns the raw BCS-encoded contents.
Sourcepub fn into_parts(self) -> (MoveObjectType, Version, Vec<u8>)
pub fn into_parts(self) -> (MoveObjectType, Version, Vec<u8>)
Consumes the object and returns its type, version, and raw contents.
Sourcepub fn to_rust<'de, T: Deserialize<'de>>(&'de self) -> Result<T, Error>
Available on crate feature serde only.
pub fn to_rust<'de, T: Deserialize<'de>>(&'de self) -> Result<T, Error>
serde only.Deserializes the BCS-encoded contents into a Rust type.
Trait Implementations§
Source§impl Arbitrary for MoveStruct
Available on crate feature proptest only.
impl Arbitrary for MoveStruct
proptest only.Source§type Parameters = ()
type Parameters = ()
arbitrary_with accepts for configuration
of the generated Strategy. Parameters must implement Default.Source§type Strategy = BoxedStrategy<MoveStruct>
type Strategy = BoxedStrategy<MoveStruct>
Strategy used to generate values of type Self.Source§fn arbitrary_with(
args_shared: <Self as Arbitrary>::Parameters,
) -> Self::Strategy
fn arbitrary_with( args_shared: <Self as Arbitrary>::Parameters, ) -> Self::Strategy
Source§impl Clone for MoveStruct
impl Clone for MoveStruct
Source§fn clone(&self) -> MoveStruct
fn clone(&self) -> MoveStruct
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MoveStruct
impl Debug for MoveStruct
Source§impl<'de> Deserialize<'de> for MoveStruct
Available on crate feature serde only.
impl<'de> Deserialize<'de> for MoveStruct
serde only.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>,
Source§impl Display for MoveStruct
impl Display for MoveStruct
impl Eq for MoveStruct
Source§impl Hash for MoveStruct
impl Hash for MoveStruct
Source§impl PartialEq for MoveStruct
impl PartialEq for MoveStruct
Source§impl Serialize for MoveStruct
Available on crate feature serde only.
impl Serialize for MoveStruct
serde only.