Skip to main content

TaleaClient

Struct TaleaClient 

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

HTTP client for a talea server, implementing LedgerApi.

Cheap to share: hold it in an Arc or clone the underlying reqwest client via the builder. Construct with TaleaClient::builder.

Implementations§

Source§

impl TaleaClient

Source

pub fn builder(base_url: impl Into<String>) -> ClientBuilder

Start building a client for the server at base_url (e.g. http://127.0.0.1:8080). A path prefix is preserved, but the base must not already include the /v1 version segment.

Trait Implementations§

Source§

impl LedgerApi for TaleaClient

Source§

fn post_batch<'life0, 'async_trait>( &'life0 self, drafts: Vec<TransactionDraft>, ) -> Pin<Box<dyn Future<Output = Vec<ApiResult<Posted>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Post a batch via one POST /v1/transactions/batch call.

Empty input returns an empty Vec immediately without any HTTP call.

Whole-request failure (401 / 415 / 400 / transport) yields the same error in every slot. Callers can detect this via all-slots- identical. Retrying the whole batch is always safe because idempotency keys dedup per draft: any slot that already committed returns deduplicated: true instead of double-posting.

Retry: the whole request goes through the standard 503/408/transport retry wrapper — safe for the same dedup reason.

Source§

fn register_asset<'life0, 'async_trait>( &'life0 self, draft: AssetDraft, ) -> Pin<Box<dyn Future<Output = ApiResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Register an asset. Idempotent on id: an identical re-registration succeeds, the same id with a different definition is AlreadyExists. Crypto assets require a network; precision is immutable forever.
Source§

fn open_account<'life0, 'async_trait>( &'life0 self, draft: AccountDraft, ) -> Pin<Box<dyn Future<Output = ApiResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Open an account in a book. Idempotent on book+path with the same rule as assets. Book names starting with ‘_’ are reserved.
Source§

fn post<'life0, 'async_trait>( &'life0 self, draft: TransactionDraft, ) -> Pin<Box<dyn Future<Output = ApiResult<Posted>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Post a balanced transaction (per-asset debits == credits, all amounts positive). Idempotent on the caller-supplied idempotency key (unique per book): a replay returns the original Posted with deduplicated: true and never double-posts — which is what makes retrying on failure unconditionally safe.
Source§

fn balance<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, book: &'life1 str, path: &'life2 str, as_of: Option<DateTime<Utc>>, ) -> Pin<Box<dyn Future<Output = ApiResult<BalanceView>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Effective (normal-side-adjusted) balance, rendered as a decimal string using the asset’s precision. as_of replays by commit time; None reads the live projection.
Source§

fn account_history<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, book: &'life1 str, path: &'life2 str, page: Page, ) -> Pin<Box<dyn Future<Output = ApiResult<Paged<PostingView>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Postings for one account, seq-ascending. page.after_seq is exclusive (resume with the last seen seq); limit counts transactions, so one transaction’s postings never split across pages. Paged::next is None once exhausted.
Source§

fn transaction<'life0, 'life1, 'async_trait>( &'life0 self, tx_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = ApiResult<TransactionView>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

A committed transaction by its id (UUID assigned at post time). Unknown ids are NotFound.
Source§

fn trial_balance<'life0, 'life1, 'async_trait>( &'life0 self, book: &'life1 str, as_of: Option<DateTime<Utc>>, ) -> Pin<Box<dyn Future<Output = ApiResult<TrialBalance>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Per-asset debit/credit sums for a book, optionally as of commit time. Every line balances when the ledger does.
Source§

fn subscribe<'life0, 'life1, 'async_trait>( &'life0 self, book: &'life1 str, from: Seq, ) -> Pin<Box<dyn Future<Output = ApiResult<EventStream>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Live event stream for a book, starting at seq from (inclusive: catch-up first, then tail). Delivery is at-least-once; consumers resume after a disconnect from their last seen EventEnvelope::seq. The HTTP client implementation does that resumption automatically.

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> 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, 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<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