pub struct Client { /* private fields */ }Expand description
The client (see the module documentation).
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(cfg: ClientConfig) -> Client
pub fn new(cfg: ClientConfig) -> Client
A client with this configuration.
Sourcepub fn with_keys(cfg: ClientConfig, keys: Arc<KeyCache>) -> Client
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).
Sourcepub fn get(&self, url: &str, limit: u64) -> Result<(u16, Vec<u8>), String>
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.
Sourcepub fn key_document(
&self,
host: &str,
refresh: bool,
) -> Result<KeyDoc, ClientError>
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.
Sourcepub fn publisher_key_document(&self, host: &str) -> Result<KeyDoc, ClientError>
pub fn publisher_key_document(&self, host: &str) -> Result<KeyDoc, ClientError>
key_document of a function’s publisher, before this mesh
computes the function (its declarations, SPEC 8.5): a fetch that got no HTTP response
is E_FOREIGN_UNAVAILABLE (spec-0.4.3), its detail first in
ClientError::detail (ClientError::foreign_detail). Since 0.2.1.
Sourcepub fn key_document_bytes(&self, host: &str) -> Option<Vec<u8>>
pub fn key_document_bytes(&self, host: &str) -> Option<Vec<u8>>
The bytes of host’s key document as last fetched.
Sourcepub fn resolve(&self, host: &str) -> Result<MeshDoc, ClientError>
pub fn resolve(&self, host: &str) -> Result<MeshDoc, ClientError>
The mesh document of host, resolved with its key document (SPEC 9.6), cached.
Sourcepub fn binding(
&self,
host: &str,
name: &str,
asof: Option<&str>,
) -> Result<Option<RemoteBinding>, ClientError>
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.
Sourcepub fn descriptor(
&self,
host: &str,
fn_hash: &str,
) -> Result<Vec<u8>, ClientError>
pub fn descriptor( &self, host: &str, fn_hash: &str, ) -> Result<Vec<u8>, ClientError>
The descriptor fn_hash names, from host (its hash checked).
Sourcepub fn keys_for_body(&self, body: &[u8]) -> Keys
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.
Sourcepub fn receipt(&self, host: &str, hash: &str) -> Result<Vec<u8>, ClientError>
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.
Sourcepub fn manifest(
&self,
host: &str,
slice_id: &str,
members_hash: &str,
) -> Result<Vec<u8>, ClientError>
pub fn manifest( &self, host: &str, slice_id: &str, members_hash: &str, ) -> Result<Vec<u8>, ClientError>
A slice manifest from host (its entry checked).
Sourcepub fn blob(&self, host: &str, sha256: &str) -> Result<Vec<u8>, ClientError>
pub fn blob(&self, host: &str, sha256: &str) -> Result<Vec<u8>, ClientError>
Blob content by SHA-256 from host (its hash checked).
Sourcepub fn cell(
&self,
host: &str,
rest: &str,
request: &Request,
) -> Result<Fetched, ClientError>
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).
Sourcepub fn reference(
&self,
host: &str,
reference: &Reference,
) -> Result<Fetched, ClientError>
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).
Sourcepub fn slice_of(
&self,
host: &str,
rest: &str,
) -> Result<(Slice, Reference), ClientError>
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.
Sourcepub fn slice_page(
&self,
host: &str,
rest: &str,
next: Option<&str>,
after: Option<BTreeMap<String, Scalar>>,
) -> Result<Fetched, ClientError>
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.
Sourcepub fn slice(
&self,
host: &str,
rest: &str,
next: Option<&str>,
) -> Result<Fetched, ClientError>
pub fn slice( &self, host: &str, rest: &str, next: Option<&str>, ) -> Result<Fetched, ClientError>
The first page of a slice (see Client::slice_page).
Sourcepub fn batch(
&self,
host: &str,
items: &[String],
requests: &[Request],
) -> Result<Batch, ClientError>
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.
Sourcepub fn versions(&self, host: &str, rest: &str) -> Result<Versions, ClientError>
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.
Sourcepub fn versions_at(&self, url: &str) -> Result<Versions, ClientError>
pub fn versions_at(&self, url: &str) -> Result<Versions, ClientError>
A page of the versions endpoint at url (a next).
Sourcepub fn parse_receipt(bytes: &[u8]) -> Result<Receipt, ClientError>
pub fn parse_receipt(bytes: &[u8]) -> Result<Receipt, ClientError>
A receipt fetched by the client, parsed.