Skip to main content

RegistryClient

Struct RegistryClient 

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

A client for one registry’s off-ledger API.

Implementations§

Source§

impl RegistryClient

Source

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

A client for the registry served at base_url.

The URL is parsed here rather than at the first request, so a typo is a configuration error the caller sees immediately — and not, as it was, a Connection failure that the SDK reports as retriable and an application retries forever.

§Errors

Error::InvalidRequest if base_url is not a URL, or an HTTP client cannot be built.

Source

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

A client using an HTTP client the caller has already configured — timeouts, proxies, a custom TLS root store. Configure it with reqwest::redirect::Policy::none(), as Self::new does: a registry answer reached through a redirect is not the registry’s.

§Errors

Error::InvalidRequest if base_url is not a URL.

Source

pub async fn info(&self) -> Result<RegistryInfo>

The registry’s own description of itself — including admin_id, which is the expectedAdmin a factory choice names.

§Errors

As any HTTP call, plus Error::UnexpectedResponse on a body that does not match the standard.

Source

pub async fn list_instruments( &self, page_size: Option<u32>, page_token: Option<&str>, ) -> Result<(Vec<Instrument>, Option<String>)>

One page of the instruments this registry issues.

Returns the page and the token for the next one, or None at the end.

§Errors

As info.

Source

pub async fn instrument( &self, instrument_id: &str, ) -> Result<Option<Instrument>>

One instrument by id, or None if this registry does not issue it.

§Errors

As info. A 404 is not an error here — not issuing an instrument is an answer — but only when the registry is the one answering it. A 404 whose body is not JSON did not come from a registry handler at all: it is a base URL one path component off, or a gateway in front of one, and reporting that as “this registry does not issue it” is the worst of both worlds. A wallet polling for an instrument would see a steady, quiet None while every other call on the same client failed loudly.

Source

pub async fn transfer_factory( &self, choice_arguments: &Value, ) -> Result<FactoryWithContext>

Resolve the transfer factory for a transfer, with its choice context.

choice_arguments is a serialized TransferFactory_Transfer with empty extraArgs — see crate::transfer(), which builds it.

§Errors

As info.

Source

pub async fn allocation_factory( &self, choice_arguments: &Value, ) -> Result<FactoryWithContext>

Resolve the allocation factory, with its choice context.

§Errors

As info.

Source

pub async fn transfer_factory_v2( &self, choice_arguments: &Value, ) -> Result<FactoryWithContext>

Resolve the V2 transfer factory, with its choice context.

POST /registry/transfer-instruction/v2/transfer-factory

§Errors

As info.

Source

pub async fn allocation_factory_v2( &self, choice_arguments: &Value, ) -> Result<FactoryWithContext>

Resolve the V2 allocation factory.

POST /registry/allocation-instruction/v2/allocation-factory

§Errors

As info.

Source

pub async fn settlement_factory_v2( &self, choice_arguments: &Value, ) -> Result<FactoryWithContext>

Resolve the settlement factory — how a V2 allocation is settled.

POST /registry/allocation/v2/settlement-factory

Note the singular allocation here against the plural allocations of the choice-context paths below. That is what the specification says, inconsistent as it looks, and a client that regularises it gets a 404 from a registry that is working correctly.

V1 has no equivalent: there, an allocation is executed through a choice context on the allocation itself. V2 settles a batch through this factory instead, which is what lets both legs of a delivery-versus- payment settle together.

§Errors

As info.

Source

pub async fn transfer_instruction_context_v2( &self, transfer_instruction_id: &str, choice: TransferInstructionChoice, request: &ChoiceContextRequest, ) -> Result<ChoiceContext>

The V2 context for a choice on an existing transfer instruction.

POST /registry/transfer-instruction/v2/{id}/choice-contexts/{choice}

§Errors

As info.

Source

pub async fn allocation_context_v2( &self, allocation_id: &str, choice: AllocationChoice, request: &ChoiceContextRequest, ) -> Result<ChoiceContext>

The V2 context for a choice on an existing allocation.

POST /registry/allocations/v2/{id}/choice-contexts/{choice} — plural, unlike the settlement factory above.

§Errors

As info, plus Error::InvalidRequest for AllocationChoice::ExecuteTransfer, which V2 does not have: settling goes through settlement_factory_v2. Refusing locally names the reason; the registry would answer 404.

Source

pub async fn allocation_instruction_context_v2( &self, allocation_instruction_id: &str, choice: AllocationInstructionChoice, request: &ChoiceContextRequest, ) -> Result<ChoiceContext>

The V2 context for a choice on an allocation instruction.

POST /registry/allocation-instruction/v2/{id}/choice-contexts/{choice}

V1 has no such endpoint — an allocation instruction there is driven entirely through the factory.

§Errors

As info.

Source

pub async fn transfer_instruction_context( &self, transfer_instruction_id: &str, choice: TransferInstructionChoice, request: &ChoiceContextRequest, ) -> Result<ChoiceContext>

The context for a choice on an existing transfer instruction.

§Errors

As info.

Source

pub async fn allocation_context( &self, allocation_id: &str, choice: AllocationChoice, request: &ChoiceContextRequest, ) -> Result<ChoiceContext>

The context for a choice on an existing allocation.

§Errors

As info.

Trait Implementations§

Source§

impl Clone for RegistryClient

Source§

fn clone(&self) -> Self

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 RegistryClient

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.

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

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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