Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

A connection to one Worgl server, which may host many mints.

Every call is a single request with no retry. Transfers and burns are idempotent, so resending one after an Error::is_transient failure is safe; a Purse does that itself. Cloning is cheap and shares the connection pool.

Implementations§

Source§

impl Client

Source

pub fn new(base_url: &str) -> Result<Self, Error>

A client for the server at base_url, such as https://mint.example.com. Requests time out after 30 seconds.

Source

pub fn with_http(http: Client, base_url: &str) -> Result<Self, Error>

A client that sends its requests through http, for custom timeouts, proxies or certificates.

Source

pub fn base_url(&self) -> &str

The server URL requests go to.

Source

pub async fn info(&self, mint: &PublicKey) -> Result<Info, Error>

GET /v1/mints/{mint}/info.

Source

pub async fn view(&self, mint: &PublicKey) -> Result<MintView, Error>

The mint’s info as a MintView, ready for a Holder: its layers are the ones the server answered with, whatever this machine’s clock says.

Source

pub async fn info_and_time( &self, mint: &PublicKey, ) -> Result<(Info, u64), Error>

info, with the time the server answered: Unix seconds by its clock, from the answer’s Date header, or by this machine’s if the answer has no Date it can read.

Source

pub async fn view_and_time( &self, mint: &PublicKey, ) -> Result<(MintView, u64), Error>

view, with the time the server answered, as info_and_time reads it. Plan the transfers due before the mint’s next rotation from it, as in Holder::refresh: the mint rotates by its server’s clock, and planning by this machine’s, if it runs slow by more than the margin, can put them past the rotation.

Source

pub async fn keys(&self, mint: &PublicKey) -> Result<KeySet, Error>

GET /v1/mints/{mint}/keys: the keys that sign the mint’s live generations, each certified by the issuer key. Fails with Error::Keys if the set is another issuer’s.

Source

pub async fn verify(&self, note: &Note) -> Result<Verified, Error>

POST /v1/verify: what the note’s mint says about it.

Source

pub async fn transfer( &self, request: &TransferRequest, ) -> Result<Vec<Note>, Error>

POST /v1/transfer: the new notes, in the order of the outputs.

Source

pub async fn burn(&self, request: &BurnRequest) -> Result<u128, Error>

POST /v1/burn: the value destroyed.

Source

pub async fn mint( &self, mint: &PublicKey, request: &MintRequest, ) -> Result<Note, Error>

POST /v1/mints/{mint}/mint: a new note, for a request signed by one of the mint’s authorities.

Source

pub async fn faucet(&self) -> Result<FaucetInfo, Error>

GET /v1/faucet, from a playground faucet: its mint and limits. The faucet is worgl-faucet, at this client’s URL, which may be its mint’s server with the faucet behind the same proxy.

Source

pub async fn ask_faucet(&self, holder: &PublicKey) -> Result<Note, Error>

POST /v1/faucet: a note of the faucet’s mint, bound to holder. Past the faucet’s limits it answers 429 with the code rate_limited or exhausted.

Source

pub async fn rotate( &self, mint: &PublicKey, token: &str, ) -> Result<RotationReport, Error>

POST /v1/mints/{mint}/rotate, with the mint’s admin token.

Source

pub async fn pause(&self, mint: &PublicKey, token: &str) -> Result<(), Error>

POST /v1/mints/{mint}/pause, with the mint’s admin token.

Source

pub async fn resume(&self, mint: &PublicKey, token: &str) -> Result<(), Error>

POST /v1/mints/{mint}/resume, with the mint’s admin token.

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

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 Debug for Client

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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.

§

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

§

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
§

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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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