pub struct RegistryClient { /* private fields */ }Expand description
A client for one registry’s off-ledger API.
Implementations§
Source§impl RegistryClient
impl RegistryClient
Sourcepub fn new(base_url: &str) -> Result<Self>
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.
Sourcepub fn with_http_client(base_url: &str, http: Client) -> Result<Self>
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.
Sourcepub async fn info(&self) -> Result<RegistryInfo>
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.
Sourcepub async fn list_instruments(
&self,
page_size: Option<u32>,
page_token: Option<&str>,
) -> Result<(Vec<Instrument>, Option<String>)>
pub async fn list_instruments( &self, page_size: Option<u32>, page_token: Option<&str>, ) -> Result<(Vec<Instrument>, Option<String>)>
Sourcepub async fn instrument(
&self,
instrument_id: &str,
) -> Result<Option<Instrument>>
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.
Sourcepub async fn transfer_factory(
&self,
choice_arguments: &Value,
) -> Result<FactoryWithContext>
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.
Sourcepub async fn allocation_factory(
&self,
choice_arguments: &Value,
) -> Result<FactoryWithContext>
pub async fn allocation_factory( &self, choice_arguments: &Value, ) -> Result<FactoryWithContext>
Sourcepub async fn transfer_factory_v2(
&self,
choice_arguments: &Value,
) -> Result<FactoryWithContext>
pub async fn transfer_factory_v2( &self, choice_arguments: &Value, ) -> Result<FactoryWithContext>
Sourcepub async fn allocation_factory_v2(
&self,
choice_arguments: &Value,
) -> Result<FactoryWithContext>
pub async fn allocation_factory_v2( &self, choice_arguments: &Value, ) -> Result<FactoryWithContext>
Sourcepub async fn settlement_factory_v2(
&self,
choice_arguments: &Value,
) -> Result<FactoryWithContext>
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.
Sourcepub async fn transfer_instruction_context_v2(
&self,
transfer_instruction_id: &str,
choice: TransferInstructionChoice,
request: &ChoiceContextRequest,
) -> Result<ChoiceContext>
pub async fn transfer_instruction_context_v2( &self, transfer_instruction_id: &str, choice: TransferInstructionChoice, request: &ChoiceContextRequest, ) -> Result<ChoiceContext>
Sourcepub async fn allocation_context_v2(
&self,
allocation_id: &str,
choice: AllocationChoice,
request: &ChoiceContextRequest,
) -> Result<ChoiceContext>
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.
Sourcepub async fn allocation_instruction_context_v2(
&self,
allocation_instruction_id: &str,
choice: AllocationInstructionChoice,
request: &ChoiceContextRequest,
) -> Result<ChoiceContext>
pub async fn allocation_instruction_context_v2( &self, allocation_instruction_id: &str, choice: AllocationInstructionChoice, request: &ChoiceContextRequest, ) -> Result<ChoiceContext>
Sourcepub async fn transfer_instruction_context(
&self,
transfer_instruction_id: &str,
choice: TransferInstructionChoice,
request: &ChoiceContextRequest,
) -> Result<ChoiceContext>
pub async fn transfer_instruction_context( &self, transfer_instruction_id: &str, choice: TransferInstructionChoice, request: &ChoiceContextRequest, ) -> Result<ChoiceContext>
Sourcepub async fn allocation_context(
&self,
allocation_id: &str,
choice: AllocationChoice,
request: &ChoiceContextRequest,
) -> Result<ChoiceContext>
pub async fn allocation_context( &self, allocation_id: &str, choice: AllocationChoice, request: &ChoiceContextRequest, ) -> Result<ChoiceContext>
Trait Implementations§
Source§impl Clone for RegistryClient
impl Clone for RegistryClient
Auto Trait Implementations§
impl !RefUnwindSafe for RegistryClient
impl !UnwindSafe for RegistryClient
impl Freeze for RegistryClient
impl Send for RegistryClient
impl Sync for RegistryClient
impl Unpin for RegistryClient
impl UnsafeUnpin for RegistryClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request