Struct stellar_client::endpoint::payment::FindPath[][src]

pub struct FindPath { /* fields omitted */ }

This endpoint represents a search for a series of assets through which to route a payment, from source asset (debited from payer) to destination asset (credited to payee). The endpoint will return any payment paths using assets available to a source account to the desired destination asset.

https://www.stellar.org/developers/horizon/reference/endpoints/path-finding.html

Example

use stellar_client::sync::Client;
use stellar_client::endpoint::{payment, Limit};
use stellar_client::resources::{Amount, AssetIdentifier, OperationKind};

let client = Client::horizon_test().unwrap();

// Cast a wide net for `create_account` operations to ensure two valid accounts.
let operations  = client.request(payment::All::default().with_limit(20)).unwrap();
let account_ids = &operations
    .records()
    .iter()
    .filter_map(|op| {
        match op.kind() {
          &OperationKind::CreateAccount(ref acct) => Some(acct.account()),
          _ => None
        }
    })
    .take(2)
    .collect::<Vec<&str>>();

let endpoint = payment::FindPath::new(
    &account_ids[0], // source_account
    &account_ids[1], // destination_account
    AssetIdentifier::Native,
    Amount::new(1)
);

// Now we issue a request for a path to payment of 1 stroop
let records = client.request(endpoint).unwrap();

assert!(records.records().len() > 0);

Methods

impl FindPath
[src]

Creates a new payment::FindPath endpoint struct. Hand this to the client in order to request series of assets through which to route a desired payment.

use stellar_client::endpoint::payment;
use stellar_client::resources::{Amount, AssetIdentifier};

let paths = payment::FindPath::new(
    "source_account",
    "destination_account",
    AssetIdentifier::new(
        "credit_alphanum4",
        Some("code".to_string()),
        Some("issuer".to_string())
    ).unwrap(),
    Amount::new(8675309)
);

Trait Implementations

impl Debug for FindPath
[src]

Formats the value using the given formatter. Read more

impl Clone for FindPath
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl IntoRequest for FindPath
[src]

The deserializable type that is expected to come back from the stellar server.

The request body to be sent to stellar. Generally this is just a () unit. Converts the implementing struct into an http request. Read more

Auto Trait Implementations

impl Send for FindPath

impl Sync for FindPath