pub struct CloudClient { /* private fields */ }Expand description
A client bound to one Cloud origin, optionally authenticated.
Implementations§
Source§impl CloudClient
impl CloudClient
Sourcepub fn answered_minor(&self) -> Option<u16>
pub fn answered_minor(&self) -> Option<u16>
The minor version of the last 2.x answer this client got (2.2 →
Some(2)); None before any answer.
pub fn new(origin: &str) -> Result<Self, CloudError>
Sourcepub fn bounded(origin: &str, total: Duration) -> Result<Self, CloudError>
pub fn bounded(origin: &str, total: Duration) -> Result<Self, CloudError>
A client whose every request ends within total (resolve, connect,
send and receive together): the bounded calls made from a tool call
(C5c, rule 3 exception).
Sourcepub fn with_token(self, instance_id: &str, access_token: &str) -> Self
pub fn with_token(self, instance_id: &str, access_token: &str) -> Self
Authenticate subsequent requests as instance_id.
pub fn origin(&self) -> &str
pub fn get(&self, path: &str) -> Result<Value, CloudError>
Sourcepub fn post(&self, path: &str, body: &Value) -> Result<Value, CloudError>
pub fn post(&self, path: &str, body: &Value) -> Result<Value, CloudError>
POST with a fresh Idempotency-Key.
Sourcepub fn post_idempotent(
&self,
path: &str,
body: &Value,
key: &str,
) -> Result<Value, CloudError>
pub fn post_idempotent( &self, path: &str, body: &Value, key: &str, ) -> Result<Value, CloudError>
POST with a caller-chosen Idempotency-Key (outbox item id).
pub fn delete(&self, path: &str) -> Result<(), CloudError>
Sourcepub fn send(
&self,
method: &str,
path: &str,
body: Option<&Value>,
extra: &[(&str, &str)],
max_body: usize,
) -> Result<CloudResponse, CloudError>
pub fn send( &self, method: &str, path: &str, body: Option<&Value>, extra: &[(&str, &str)], max_body: usize, ) -> Result<CloudResponse, CloudError>
Any request; extra headers win over the defaults, max_body bounds
the response. 2xx and 304 are Ok, everything else maps to CloudError.
Sourcepub fn get_bytes(
&self,
path: &str,
max_body: usize,
) -> Result<Vec<u8>, CloudError>
pub fn get_bytes( &self, path: &str, max_body: usize, ) -> Result<Vec<u8>, CloudError>
GET of raw bytes (at most max_body), e.g. a file Cloud stores.
Sourcepub fn send_answer(
&self,
method: &str,
path: &str,
body: Option<&Value>,
max_body: usize,
) -> Result<(u16, Value), CloudError>
pub fn send_answer( &self, method: &str, path: &str, body: Option<&Value>, max_body: usize, ) -> Result<(u16, Value), CloudError>
Any request, answering its status and JSON body even when that is an
error, for C0 2.0 routes whose error.reason the caller words
itself; transport failures are still errors.
Sourcepub fn send_answer_with(
&self,
method: &str,
path: &str,
body: Option<&Value>,
extra: &[(&str, &str)],
max_body: usize,
) -> Result<(u16, Value), CloudError>
pub fn send_answer_with( &self, method: &str, path: &str, body: Option<&Value>, extra: &[(&str, &str)], max_body: usize, ) -> Result<(u16, Value), CloudError>
Self::send_answer with extra headers, which win over the
defaults (as Self::send); a caller’s Idempotency-Key, as
Self::post_idempotent sends it.
Sourcepub fn put_bytes_answer(
&self,
path: &str,
bytes: &[u8],
max_body: usize,
) -> Result<(u16, Value), CloudError>
pub fn put_bytes_answer( &self, path: &str, bytes: &[u8], max_body: usize, ) -> Result<(u16, Value), CloudError>
PUT of raw bytes (application/octet-stream), answering its status
and JSON body even when that is an error (E51 bundle upload).
Sourcepub fn send_json_bytes_answer(
&self,
method: &str,
path: &str,
body: &[u8],
max_body: usize,
) -> Result<(u16, Value), CloudError>
pub fn send_json_bytes_answer( &self, method: &str, path: &str, body: &[u8], max_body: usize, ) -> Result<(u16, Value), CloudError>
A JSON body the caller already encoded (application/json), answering
its status and JSON body even when that is an error. The caller owns
the buffer and can wipe it; the HTTP stack may still copy it while
sending (runner add, local-read-v1 §45).
Sourcepub fn get_bytes_answer(
&self,
path: &str,
max_body: usize,
) -> Result<(u16, Vec<u8>, Value), CloudError>
pub fn get_bytes_answer( &self, path: &str, max_body: usize, ) -> Result<(u16, Vec<u8>, Value), CloudError>
GET of raw bytes (at most max_body), answering the status and the
bytes; an error body is parsed as JSON (Null when it is none).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for CloudClient
impl !RefUnwindSafe for CloudClient
impl !UnwindSafe for CloudClient
impl Forget for CloudClient
impl Move for CloudClient
impl Send for CloudClient
impl Sync for CloudClient
impl Unpin for CloudClient
impl UnsafeUnpin for CloudClientwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const ArcInner<Config> is !null: UnsafeUnpin,
PhantomData<ArcInner<Config>>: UnsafeUnpin,
*const ArcInner<ConnectionPool> is !null: UnsafeUnpin,
PhantomData<ArcInner<ConnectionPool>>: UnsafeUnpin,
*const ArcInner<dyn Resolver> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Resolver>>: UnsafeUnpin,
*const ArcInner<dyn Fn(&ConnectionDetails<'_>) -> Result<Box<dyn Transport>, Error> + Send + Sync> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Fn(&ConnectionDetails<'_>) -> Result<Box<dyn Transport>, Error> + Send + Sync>>: UnsafeUnpin,
Align2<u16>: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more