pub struct Object {
pub data: ObjectData,
pub owner: Owner,
pub previous_transaction: TransactionDigest,
pub storage_rebate: u64,
}Expand description
An object on the IOTA blockchain
§BCS
The BCS serialized form for this type is defined by the following ABNF:
object = object-data owner digest u64Fields§
§data: ObjectDataThe meat of the object
owner: OwnerThe owner that unlocks this object
previous_transaction: TransactionDigestThe digest of the transaction that created or last mutated this object
storage_rebate: u64The amount of IOTA we would rebate if this object gets deleted. This number is re-calculated each time the object is mutated based on the present storage gas price.
Implementations§
Source§impl Object
impl Object
Sourcepub fn digest(&self) -> ObjectDigest
Available on crate features hash and serde only.
pub fn digest(&self) -> ObjectDigest
hash and serde only.Calculate the digest of this Object
This is done by hashing the BCS bytes of this Object prefixed
with a salt.
Source§impl Object
impl Object
Sourcepub fn new(
data: ObjectData,
owner: Owner,
previous_transaction: TransactionDigest,
storage_rebate: u64,
) -> Self
pub fn new( data: ObjectData, owner: Owner, previous_transaction: TransactionDigest, storage_rebate: u64, ) -> Self
Build an object
Sourcepub fn object_ref(&self) -> ObjectReference
Available on crate features hash and serde only.
pub fn object_ref(&self) -> ObjectReference
hash and serde only.Return this object’s reference
Sourcepub fn object_type(&self) -> ObjectType
pub fn object_type(&self) -> ObjectType
Return this object’s type
Sourcepub fn as_opt_struct(&self) -> Option<&MoveStruct>
pub fn as_opt_struct(&self) -> Option<&MoveStruct>
Try to interpret this object as a move struct
Sourcepub fn as_struct(&self) -> &MoveStruct
pub fn as_struct(&self) -> &MoveStruct
Interpret this object as a move struct
Sourcepub fn as_opt_package(&self) -> Option<&MovePackage>
pub fn as_opt_package(&self) -> Option<&MovePackage>
Try to interpret this object as a move package
Sourcepub fn as_package(&self) -> &MovePackage
pub fn as_package(&self) -> &MovePackage
Interpret this object as a move package
Sourcepub fn data(&self) -> &ObjectData
pub fn data(&self) -> &ObjectData
Return this object’s data
Sourcepub fn previous_transaction(&self) -> TransactionDigest
pub fn previous_transaction(&self) -> TransactionDigest
Return the digest of the transaction that last modified this object
Sourcepub fn storage_rebate(&self) -> u64
pub fn storage_rebate(&self) -> u64
Return the storage rebate locked in this object
Storage rebates are credited to the gas coin used in a transaction that deletes this object.
pub fn to_rust<'de, T: Deserialize<'de>>( &'de self, ) -> Result<T, Box<dyn Error + Send + Sync>>
serde only.Sourcepub fn is_immutable(&self) -> bool
pub fn is_immutable(&self) -> bool
Returns true if the object is immutable.
Sourcepub fn is_address_owned(&self) -> bool
pub fn is_address_owned(&self) -> bool
Returns true if the object is owned by an address.
Sourcepub fn is_child_object(&self) -> bool
pub fn is_child_object(&self) -> bool
Returns true if the object is owned by another object.
Returns true if the object is shared.
Sourcepub fn is_package(&self) -> bool
pub fn is_package(&self) -> bool
Returns true if this object is a Move package rather than a Move value.
Sourcepub fn is_system_package(&self) -> bool
pub fn is_system_package(&self) -> bool
Returns true if the object is a system package.
Sourcepub fn struct_tag(&self) -> Option<StructTag>
pub fn struct_tag(&self) -> Option<StructTag>
Returns the struct tag of this object if it is a Move struct.
Sourcepub fn is_gas_coin(&self) -> bool
pub fn is_gas_coin(&self) -> bool
Returns true if this object is a gas coin.
Sourcepub fn opt_coin_type(&self) -> Option<&TypeTag>
pub fn opt_coin_type(&self) -> Option<&TypeTag>
Returns the coin’s type parameter if this object is a coin.
Sourcepub fn single_owner(&self) -> Option<Address>
pub fn single_owner(&self) -> Option<Address>
Returns the address of the single owner of this object (address- or
object-owned), or None if it is shared or immutable.
Source§impl Object
impl Object
Sourcepub fn to_bcs(&self) -> Vec<u8> ⓘ
Available on crate feature serde only.
pub fn to_bcs(&self) -> Vec<u8> ⓘ
serde only.Serialize this Object as a Vec<u8> of BCS bytes.
Sourcepub fn to_base64(&self) -> String
Available on crate feature serde only.
pub fn to_base64(&self) -> String
serde only.Serialize this Object as a base64-encoded string of its BCS bytes.
Sourcepub fn from_bcs(bytes: &[u8]) -> Result<Self, Error>
Available on crate feature serde only.
pub fn from_bcs(bytes: &[u8]) -> Result<Self, Error>
serde only.Deserialize a Object from BCS bytes.
Sourcepub fn from_base64(bytes: &str) -> Result<Self, Error>
Available on crate feature serde only.
pub fn from_base64(bytes: &str) -> Result<Self, Error>
serde only.Deserialize a Object from a base64-encoded string of its BCS bytes.
Trait Implementations§
Source§impl Arbitrary for Object
Available on crate feature proptest only.
impl Arbitrary for Object
proptest only.Source§type Parameters = ()
type Parameters = ()
arbitrary_with accepts for configuration
of the generated Strategy. Parameters must implement Default.Source§type Strategy = BoxedStrategy<Object>
type Strategy = BoxedStrategy<Object>
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<'de> Deserialize<'de> for Object
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Object
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>,
impl Eq for Object
impl StructuralPartialEq for Object
Source§impl TryFrom<Object> for NameRecord
Available on crate feature serde only.
impl TryFrom<Object> for NameRecord
serde only.