Skip to main content

Vault

Struct Vault 

Source
pub struct Vault<'a> {
Show 16 fields pub common_fields: CommonFields<'a, VaultFlag>, pub owner: Cow<'a, str>, pub account: Cow<'a, str>, pub asset: Currency<'a>, pub assets_total: Option<Cow<'a, str>>, pub assets_available: Option<Cow<'a, str>>, pub assets_maximum: Option<Cow<'a, str>>, pub loss_unrealized: Option<Cow<'a, str>>, pub share_mpt_id: Cow<'a, str>, pub withdrawal_policy: u8, pub scale: Option<u8>, pub sequence: u32, pub data: Option<Cow<'a, str>>, pub owner_node: Cow<'a, str>, pub previous_txn_id: Cow<'a, str>, pub previous_txn_lgr_seq: u32,
}
Expand description

The Vault object type describes a single-asset vault instance (XLS-65).

All string fields use Cow<'a, str>. Vault objects are constructed by the server; callers should treat all fields as read-only.

Note: the ideal field type for server-read-only strings is &'a str (zero-copy, immutable). However, switching to &'a str with #[serde(borrow)] requires the 'de: 'a lifetime constraint to propagate through the entire LedgerEntryBaseLedgerLedgerV1 chain, which affects all other ledger objects. A follow-up PR should migrate Vault, AccountRoot, MPToken, and MPTokenIssuance to &'a str together as part of a codebase-wide ledger-object cleanup.

<https://github.com/XRPLF/XRPL-Standards/tree/master/XLS-0065-single-asset-vault>

Fields§

§common_fields: CommonFields<'a, VaultFlag>

The base fields for all ledger object models.

See Ledger Object Common Fields: <https://xrpl.org/ledger-entry-common-fields.html>

§owner: Cow<'a, str>

The account address of the Vault Owner. (SoeRequired)

§account: Cow<'a, str>

The address of the Vault’s pseudo-account. (SoeRequired)

§asset: Currency<'a>

The asset of the vault (XRP, IOU or MPT). (SoeRequired)

§assets_total: Option<Cow<'a, str>>

The total value of the vault. (SoeDefault)

§assets_available: Option<Cow<'a, str>>

The asset amount that is available in the vault. (SoeDefault)

§assets_maximum: Option<Cow<'a, str>>

The maximum asset amount that can be held in the vault. Zero means no cap. (SoeOptional)

§loss_unrealized: Option<Cow<'a, str>>

The potential loss amount that is not yet realized, expressed as the vault’s asset. (SoeDefault)

§share_mpt_id: Cow<'a, str>

The identifier of the share MPTokenIssuance object. (SoeRequired)

§withdrawal_policy: u8

Indicates the withdrawal strategy used by the Vault. (SoeRequired)

§scale: Option<u8>

The Scale specifies the power of 10 to multiply an asset’s value by when converting it into an integer-based number of shares. (SoeDefault)

§sequence: u32

The transaction sequence number that created the vault. (SoeRequired)

§data: Option<Cow<'a, str>>

Arbitrary metadata about the Vault. Limited to 256 bytes. (SoeOptional)

§owner_node: Cow<'a, str>

A hint indicating which page of the owner’s directory links to this object. (SoeRequired)

§previous_txn_id: Cow<'a, str>

The identifying hash of the transaction that most recently modified this object.

§previous_txn_lgr_seq: u32

The index of the ledger that contains the transaction that most recently modified this object.

Implementations§

Source§

impl<'a> Vault<'a>

Source

pub fn new( flags: FlagCollection<VaultFlag>, index: Option<Cow<'a, str>>, owner: Cow<'a, str>, account: Cow<'a, str>, asset: Currency<'a>, share_mpt_id: Cow<'a, str>, withdrawal_policy: u8, sequence: u32, owner_node: Cow<'a, str>, previous_txn_id: Cow<'a, str>, previous_txn_lgr_seq: u32, ) -> Self

Create a new Vault with required fields; optional fields default to None.

Trait Implementations§

Source§

impl<'a> Clone for Vault<'a>

Source§

fn clone(&self) -> Vault<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Vault<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, 'a> Deserialize<'de> for Vault<'a>

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'a> Eq for Vault<'a>

Source§

impl<'a> LedgerObject<VaultFlag> for Vault<'a>

Source§

impl<'a> Model for Vault<'a>

Source§

fn get_errors(&self) -> XRPLModelResult<()>

Collects a models errors and returns the first error that occurs.
Source§

fn validate(&self) -> XRPLModelResult<()>

Simply forwards the error from get_errors if there was one.
Source§

fn is_valid(&self) -> bool

Checks if the model is valid.
Source§

impl<'a> PartialEq for Vault<'a>

Source§

fn eq(&self, other: &Vault<'a>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> Serialize for Vault<'a>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'a> StructuralPartialEq for Vault<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Vault<'a>

§

impl<'a> RefUnwindSafe for Vault<'a>

§

impl<'a> Send for Vault<'a>

§

impl<'a> Sync for Vault<'a>

§

impl<'a> Unpin for Vault<'a>

§

impl<'a> UnsafeUnpin for Vault<'a>

§

impl<'a> UnwindSafe for Vault<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more