Struct casper_types::URef
source · 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 CLValue
s, 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§fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> URef
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> URef
T
, using rng
as the source of randomness.source§impl Ord for URef
impl Ord for URef
source§impl PartialEq for URef
impl PartialEq for URef
source§impl PartialOrd for URef
impl PartialOrd for URef
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§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.