Struct offchain::identifier::Intent
source · pub struct Intent { /* private fields */ }
Expand description
Intent is a struct holdind data decoded from Diem Intent Identifier string https://dip.diem.com/dip-5/#format
Implementations§
source§impl Intent
impl Intent
sourcepub fn to_encoded_string(&self) -> Result<String, IntentIdentifierError>
pub fn to_encoded_string(&self) -> Result<String, IntentIdentifierError>
Encode Intent as a Diem intent identifier (https://dip.diem.com/dip-5/).
Example
use offchain::identifier::Intent;
use std::str::FromStr;
let identifier = "diem://dm1p7ujcndcl7nudzwt8fglhx6wxn08kgs5tm6mz4us2vfufk?c=XUS&am=4500";
let intent = Intent::from_str(identifier).unwrap();
assert_eq!(intent.to_encoded_string().unwrap(), identifier);
pub fn account_address(&self) -> &AccountAddress
pub fn subaddress(&self) -> &Subaddress
pub fn currency(&self) -> Option<Currency>
pub fn amount(&self) -> Option<u64>
pub fn hrp(&self) -> &HumanReadablePrefix
Trait Implementations§
source§impl FromStr for Intent
impl FromStr for Intent
source§fn from_str(
encoded_intent_identifier: &str
) -> Result<Intent, IntentIdentifierError>
fn from_str( encoded_intent_identifier: &str ) -> Result<Intent, IntentIdentifierError>
Decode Diem intent identifier (https://dip.diem.com/dip-5/) int 3 parts:
- account identifier: account address & sub-address
- currency
- amount
Example
use offchain::identifier::HumanReadablePrefix;
use offchain::identifier::Intent;
use std::str::FromStr;
let identifier = "diem://dm1p7ujcndcl7nudzwt8fglhx6wxn08kgs5tm6mz4us2vfufk?c=XUS&am=4500";
let intent = Intent::from_str(identifier).unwrap();
assert_eq!(intent.hrp(), &HumanReadablePrefix::DM);
assert_eq!(intent.amount(), Some(4500));
§type Err = IntentIdentifierError
type Err = IntentIdentifierError
The associated error which can be returned from parsing.
source§impl Ord for Intent
impl Ord for Intent
source§impl PartialEq<Intent> for Intent
impl PartialEq<Intent> for Intent
source§impl PartialOrd<Intent> for Intent
impl PartialOrd<Intent> for Intent
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Eq for Intent
impl StructuralEq for Intent
impl StructuralPartialEq for Intent
Auto Trait Implementations§
impl RefUnwindSafe for Intent
impl Send for Intent
impl Sync for Intent
impl Unpin for Intent
impl UnwindSafe for Intent
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.