pub struct MuxedAddress { /* private fields */ }
Expand description
MuxedAddress is a union type that represents either the regular Address
,
or a ‘multiplexed’ address that consists of a regular address and a u64 id
and can be used for representing the ‘virtual’ accounts that allows for
managing multiple balances off-chain with only a single on-chain balance
entry. The address part can be used as a regular Address
, and the id
part should be used only in the events for the off-chain processing.
This type is only necessary in a few special cases, such as token transfers
that support non-custodial accounts (e.g. for the exchange support). Prefer
using the regular Address
type unless multiplexing support is necessary.
This type is compatible with Address
at the contract interface level, i.e.
if a contract accepts MuxedAddress
as an input, then its callers may still
pass Address
into the call successfully. This means that if a
contract has upgraded its interface to switch from Address
argument to
MuxedAddress
argument, it won’t break any of its existing clients.
Currently only the regular Stellar accounts can be multiplexed, i.e. multiplexed contract addresses don’t exist.
Note, that multiplexed addresses can not be used directly as a storage key.
This is a precaution to prevent accidental unexpected fragmentation of
the key space (like creating an arbitrary number of balances for the same
actual Address
).
Implementations§
Source§impl MuxedAddress
impl MuxedAddress
Sourcepub fn address(&self) -> Address
pub fn address(&self) -> Address
Returns the Address
part of this multiplexed address.
The address part is necessary to perform most of the operations, such as authorization or storage.
Sourcepub fn id(&self) -> Option<u64>
pub fn id(&self) -> Option<u64>
Returns the multiplexing identifier part of this multiplexed address, if any.
Returns None
for the regular (non-multiplexed) addresses.
This identifier should normally be used in the events in order to allow for tracking the virtual balances associated with this address off-chain.
pub fn env(&self) -> &Env
pub fn as_val(&self) -> &Val
pub fn to_val(&self) -> Val
Trait Implementations§
Source§impl Clone for MuxedAddress
impl Clone for MuxedAddress
Source§fn clone(&self) -> MuxedAddress
fn clone(&self) -> MuxedAddress
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for MuxedAddress
impl Debug for MuxedAddress
Source§impl From<&Address> for MuxedAddress
impl From<&Address> for MuxedAddress
Source§impl From<&MuxedAddress> for MuxedAddress
impl From<&MuxedAddress> for MuxedAddress
Source§fn from(address: &MuxedAddress) -> Self
fn from(address: &MuxedAddress) -> Self
Source§impl From<Address> for MuxedAddress
impl From<Address> for MuxedAddress
Source§impl MuxedAddress for MuxedAddress
Available on crate feature testutils
only.
impl MuxedAddress for MuxedAddress
testutils
only.Source§fn generate(env: &Env) -> MuxedAddress
fn generate(env: &Env) -> MuxedAddress
Address
and id parts. Read moreSource§fn new<T: Into<MuxedAddress>>(address: T, id: u64) -> MuxedAddress
fn new<T: Into<MuxedAddress>>(address: T, id: u64) -> MuxedAddress
MuxedAddress
that has the same Address
part as the
provided address
and the provided multiplexing id. Read moreSource§impl Ord for MuxedAddress
impl Ord for MuxedAddress
Source§impl PartialEq for MuxedAddress
impl PartialEq for MuxedAddress
Source§impl PartialOrd for MuxedAddress
impl PartialOrd for MuxedAddress
Source§impl TryFromVal<Env, &MuxedAddress> for Val
impl TryFromVal<Env, &MuxedAddress> for Val
type Error = ConversionError
fn try_from_val(_env: &Env, v: &&MuxedAddress) -> Result<Self, Self::Error>
Source§impl TryFromVal<Env, AddressObject> for MuxedAddress
impl TryFromVal<Env, AddressObject> for MuxedAddress
type Error = Infallible
fn try_from_val(env: &Env, val: &AddressObject) -> Result<Self, Self::Error>
Source§impl TryFromVal<Env, MuxedAddress> for Val
impl TryFromVal<Env, MuxedAddress> for Val
type Error = ConversionError
fn try_from_val(_env: &Env, v: &MuxedAddress) -> Result<Self, Self::Error>
Source§impl TryFromVal<Env, MuxedAddressObject> for MuxedAddress
impl TryFromVal<Env, MuxedAddressObject> for MuxedAddress
type Error = Infallible
fn try_from_val( env: &Env, val: &MuxedAddressObject, ) -> Result<Self, Self::Error>
Source§impl TryFromVal<Env, ScAddress> for MuxedAddress
impl TryFromVal<Env, ScAddress> for MuxedAddress
Source§impl TryFromVal<Env, ScVal> for MuxedAddress
impl TryFromVal<Env, ScVal> for MuxedAddress
Source§impl TryFromVal<Env, Val> for MuxedAddress
impl TryFromVal<Env, Val> for MuxedAddress
impl Eq for MuxedAddress
Auto Trait Implementations§
impl Freeze for MuxedAddress
impl !RefUnwindSafe for MuxedAddress
impl !Send for MuxedAddress
impl !Sync for MuxedAddress
impl Unpin for MuxedAddress
impl !UnwindSafe for MuxedAddress
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<T, U, V, W, E, C> Compare<(T, U, V, W)> for C
impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for C
type Error = E
fn compare( &self, a: &(T, U, V, W), b: &(T, U, V, W), ) -> Result<Ordering, <C as Compare<(T, U, V, W)>>::Error>
Source§impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for C
impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for C
type Error = E
fn compare( &self, a: &(T, U, V, W, X), b: &(T, U, V, W, X), ) -> Result<Ordering, <C as Compare<(T, U, V, W, X)>>::Error>
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.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§impl<E, T, U> FromVal<E, T> for Uwhere
E: Env,
U: TryFromVal<E, T>,
impl<E, T, U> FromVal<E, T> for Uwhere
E: Env,
U: TryFromVal<E, T>,
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