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 DataSize for URef
impl DataSize for URef
Source§const IS_DYNAMIC: bool = false
const IS_DYNAMIC: bool = false
true, the type has a heap size that can vary at runtime, depending on the actual value.Source§const STATIC_HEAP_SIZE: usize = 0usize
const STATIC_HEAP_SIZE: usize = 0usize
IS_DYNAMIC is false, this is
the total amount of heap memory occupied by the value. Otherwise this is a lower bound.Source§fn estimate_heap_size(&self) -> usize
fn estimate_heap_size(&self) -> usize
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
Available on crate feature testing only.
impl Distribution<URef> for Standard
testing only.Source§impl From<URef> for DelegatorKind
impl From<URef> for DelegatorKind
Source§impl From<URef> for TransferTarget
impl From<URef> for TransferTarget
Source§impl JsonSchema for URef
Available on crate feature json-schema only.
impl JsonSchema for URef
json-schema only.Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read moreSource§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.impl Copy for URef
impl Eq for URef
impl StructuralPartialEq for URef
Auto Trait Implementations§
impl Freeze for URef
impl RefUnwindSafe for URef
impl Send for URef
impl Sync for URef
impl Unpin for URef
impl UnwindSafe for URef
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more