Skip to main content

Client

Struct Client 

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

The client (see the module documentation).

Implementations§

Source§

impl Client

Source

pub fn new(cfg: ClientConfig) -> Client

A client with this configuration.

Source

pub fn with_keys(cfg: ClientConfig, keys: Arc<KeyCache>) -> Client

A client sharing a key cache (the mesh’s, so POST /verify sees what it fetched).

Source

pub fn keys(&self) -> &Arc<KeyCache> ⓘ

The key cache.

Source

pub fn allowed(&self, host: &str) -> bool

Whether host may be fetched from.

Source

pub fn get(&self, url: &str, limit: u64) -> Result<(u16, Vec<u8>), String>

GET url (an https://<host>/... URL; the origin replaced for a configured peer): status and body, at most limit bytes.

Source

pub fn key_document( &self, host: &str, refresh: bool, ) -> Result<KeyDoc, ClientError>

The key document of host (SPEC 9.3), from the cache while it is fresh, else fetched; refresh fetches it again unless it was fetched within the refetch interval.

Source

pub fn key_document_bytes(&self, host: &str) -> Option<Vec<u8>>

The bytes of host’s key document as last fetched.

Source

pub fn resolve(&self, host: &str) -> Result<MeshDoc, ClientError>

The mesh document of host, resolved with its key document (SPEC 9.6), cached.

Source

pub fn binding( &self, host: &str, name: &str, asof: Option<&str>, ) -> Result<Option<RemoteBinding>, ClientError>

The binding of name that host’s bindings resource states as of asof (now when None), SPEC 9.7.

Source

pub fn descriptor( &self, host: &str, fn_hash: &str, ) -> Result<Vec<u8>, ClientError>

The descriptor fn_hash names, from host (its hash checked).

Source

pub fn keys_for_body(&self, body: &[u8]) -> Keys

The keys of the signers named in a body (a receipt, an envelope, a page or a batch): each signer’s key document, from its own host.

Source

pub fn receipt(&self, host: &str, hash: &str) -> Result<Vec<u8>, ClientError>

A receipt by its hash from host: its hash checked and its signature verified (SPEC 10.1 steps 1-6) against its signer’s key document.

Source

pub fn manifest( &self, host: &str, slice_id: &str, members_hash: &str, ) -> Result<Vec<u8>, ClientError>

A slice manifest from host (its entry checked).

Source

pub fn blob(&self, host: &str, sha256: &str) -> Result<Vec<u8>, ClientError>

Blob content by SHA-256 from host (its hash checked).

Source

pub fn cell( &self, host: &str, rest: &str, request: &Request, ) -> Result<Fetched, ClientError>

The envelope for rest (a cell URI’s rest or a call, as the cell endpoint takes it) from host, checked against request (5.5; the host asked is added to it).

Source

pub fn reference( &self, host: &str, reference: &Reference, ) -> Result<Fetched, ClientError>

The envelope of a reference (pinned or not) from host: its URI written by the core, the request it describes made from it (the cell id needs the function hash: the pin, else the binding host states as of the reference’s asof).

Source

pub fn slice_of( &self, host: &str, rest: &str, ) -> Result<(Slice, Reference), ClientError>

The slice a slice URI’s rest denotes on host: the descriptor of its pin, or of the name’s binding (as of its asof), parsed against.

Source

pub fn slice_page( &self, host: &str, rest: &str, next: Option<&str>, after: Option<BTreeMap<String, Scalar>>, ) -> Result<Fetched, ClientError>

A page of a slice from host (5.6): the first page of rest (a slice URI’s rest), or, with next, the page that URL names (which must be on host), checked against the slice rest denotes and, for a following page, the cursor after.

Source

pub fn slice( &self, host: &str, rest: &str, next: Option<&str>, ) -> Result<Fetched, ClientError>

The first page of a slice (see Client::slice_page).

Source

pub fn batch( &self, host: &str, items: &[String], requests: &[Request], ) -> Result<Batch, ClientError>

A batch (5.7) to host: the requests’ rests and the request each describes, checked as a whole and item by item.

Source

pub fn versions(&self, host: &str, rest: &str) -> Result<Versions, ClientError>

The versions of a stored cell from host (9.8): rest is its URI’s rest without asof.

Source

pub fn versions_at(&self, url: &str) -> Result<Versions, ClientError>

A page of the versions endpoint at url (a next).

Source

pub fn parse_receipt(bytes: &[u8]) -> Result<Receipt, ClientError>

A receipt fetched by the client, parsed.

Trait Implementations§

Source§

impl Clone for Client

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 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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