Skip to main content

CloudClient

Struct CloudClient 

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

A client bound to one Cloud origin, optionally authenticated.

Implementations§

Source§

impl CloudClient

Source

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.

Source

pub fn new(origin: &str) -> Result<Self, CloudError>

Source

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).

Source

pub fn with_token(self, instance_id: &str, access_token: &str) -> Self

Authenticate subsequent requests as instance_id.

Source

pub fn origin(&self) -> &str

Source

pub fn get(&self, path: &str) -> Result<Value, CloudError>

Source

pub fn post(&self, path: &str, body: &Value) -> Result<Value, CloudError>

POST with a fresh Idempotency-Key.

Source

pub fn post_idempotent( &self, path: &str, body: &Value, key: &str, ) -> Result<Value, CloudError>

POST with a caller-chosen Idempotency-Key (outbox item id).

Source

pub fn delete(&self, path: &str) -> Result<(), CloudError>

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Source

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).

Source

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§

Source§

impl PlaceApi for CloudClient

Source§

fn get(&self, path: &str) -> Result<Value, CloudError>

Source§

fn get_bytes(&self, path: &str, max: usize) -> Result<Vec<u8>, CloudError>

Source§

fn post(&self, path: &str, body: &Value) -> Result<Value, CloudError>

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
where RawVecInner: Send, Arc<Config>: Send, Arc<ConnectionPool>: Send, Arc<dyn Resolver>: Send, Arc<dyn Fn(&ConnectionDetails<'_>) -> Result<Box<dyn Transport>, Error> + Send + Sync>: Send, Atomic<u16>: Send,

§

impl Sync for CloudClient
where RawVecInner: Sync, Arc<Config>: Sync, Arc<ConnectionPool>: Sync, Arc<dyn Resolver>: Sync, Arc<dyn Fn(&ConnectionDetails<'_>) -> Result<Box<dyn Transport>, Error> + Send + Sync>: Sync, Atomic<u16>: Sync,

§

impl Unpin for CloudClient
where *const u8 is !null: Unpin, Arc<Config>: Unpin, Arc<ConnectionPool>: Unpin, Arc<dyn Resolver>: Unpin, Arc<dyn Fn(&ConnectionDetails<'_>) -> Result<Box<dyn Transport>, Error> + Send + Sync>: Unpin, Align2<u16>: Unpin,

§

impl UnsafeUnpin for CloudClient
where *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> 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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> 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, 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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