pub struct URef(/* private fields */);Expand description
Represents an unforgeable reference, containing an address in the network’s global storage and
the AccessRights of the reference.
A URef can be used to index entities such as CLValues, or smart contracts.
Implementations§
Source§impl URef
impl URef
Sourcepub const fn new(address: URefAddr, access_rights: AccessRights) -> Self
pub const fn new(address: URefAddr, access_rights: AccessRights) -> Self
Constructs a URef from an address and access rights.
Sourcepub fn access_rights(&self) -> AccessRights
pub fn access_rights(&self) -> AccessRights
Returns the access rights of this URef.
Sourcepub fn with_access_rights(self, access_rights: AccessRights) -> Self
pub fn with_access_rights(self, access_rights: AccessRights) -> Self
Returns a new URef with the same address and updated access rights.
Sourcepub fn remove_access_rights(self) -> Self
pub fn remove_access_rights(self) -> Self
Removes the access rights from this URef.
Sourcepub fn is_readable(self) -> bool
pub fn is_readable(self) -> bool
Returns true if the access rights are Some and
is_readable is true for them.
Sourcepub fn into_read(self) -> URef
pub fn into_read(self) -> URef
Returns a new URef with the same address and AccessRights::READ permission.
Sourcepub fn into_write(self) -> URef
pub fn into_write(self) -> URef
Returns a new URef with the same address and AccessRights::WRITE permission.
Sourcepub fn into_add(self) -> URef
pub fn into_add(self) -> URef
Returns a new URef with the same address and AccessRights::ADD permission.
Sourcepub fn into_read_add_write(self) -> URef
pub fn into_read_add_write(self) -> URef
Returns a new URef with the same address and AccessRights::READ_ADD_WRITE
permission.
Sourcepub fn into_read_write(self) -> URef
pub fn into_read_write(self) -> URef
Returns a new URef with the same address and AccessRights::READ_WRITE
permission.
Sourcepub fn is_writeable(self) -> bool
pub fn is_writeable(self) -> bool
Returns true if the access rights are Some and
is_writeable is true for them.
Sourcepub fn is_addable(self) -> bool
pub fn is_addable(self) -> bool
Returns true if the access rights are Some and is_addable
is true for them.
Sourcepub fn to_formatted_string(self) -> String
pub fn to_formatted_string(self) -> String
Formats the address and access rights of the URef in a unique way that could be used as
a name when storing the given URef in a global state.
Sourcepub fn from_formatted_str(input: &str) -> Result<Self, FromStrError>
pub fn from_formatted_str(input: &str) -> Result<Self, FromStrError>
Parses a string formatted as per Self::to_formatted_string() into a URef.
Sourcepub fn disable_access_rights(&mut self, access_rights: AccessRights)
pub fn disable_access_rights(&mut self, access_rights: AccessRights)
Removes specific access rights from this URef if present.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for URef
impl<'de> Deserialize<'de> for URef
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl Distribution<URef> for Standard
impl Distribution<URef> for Standard
Source§impl Ord for URef
impl Ord for URef
Source§impl PartialOrd for URef
impl PartialOrd for URef
Source§impl ToBytes for URef
impl ToBytes for URef
Source§fn serialized_length(&self) -> usize
fn serialized_length(&self) -> usize
Vec<u8> which would be returned from a successful call to
to_bytes() or into_bytes(). The data is not actually serialized, so this call is
relatively cheap.