2 releases
Uses old Rust 2015
0.1.2 | Aug 20, 2018 |
---|---|
0.1.1 | Apr 20, 2018 |
0.1.0 |
|
#25 in #horizon
360KB
8K
SLoC
Stellar Client
A crate that enables interacting with the stellar horizon api.
Endpoints
An endpoint is a trait that embodies the two way nature of an API. On the one hand it deines what is returned from the API as strict types but it also defines what needs to be specified to make the requests in the first place.
Having this captured in a type allows us to reason about it in the abstract and model the abstraction primitives going into and out of horizon.
lib.rs
:
Stellar Client
A light-weight implementation to the stellar horizon api.
There are three main aspects to the client library. There is the client itself found in the client module. There are the various endpoints that can be used to fetch data. And then there are the resources themselves that are returned from the APIs.
Usage and Examples
To use, first create a client. For simplicity this example will use the synchronous client and will use it to fetch a random asset and then ask if there are any trades between that asset and lumens.
use stellar_client::{
sync::Client,
endpoint::{asset, trade},
resources::AssetIdentifier,
};
// Creates a client that's connected to stellar's test net
let client = Client::horizon_test().unwrap();
// Creates a request-like struct for all assets
let assets = asset::All::default();
// Issues request for assets and grabs identifier
let assets = client.request(assets).unwrap();
let identifier = assets.records()[0].identifier();
// Form a request for trades
let trades = trade::All::default()
.with_asset_pair(AssetIdentifier::native(), identifier.clone());
let trades = client.request(trades).unwrap();
Dependencies
~16–25MB
~449K SLoC