Skip to main content

CheckedResponseGuard

Struct CheckedResponseGuard 

Source
pub struct CheckedResponseGuard<'buffer, 'sanitizer, S: ResponseStorageSanitizer + ?Sized> { /* private fields */ }
Expand description

Policy-checked response that owns cleanup of its caller storage.

Borrowed access is closure-scoped. Self::decode_owned clears the complete response storage before returning the owned decoded result.

Implementations§

Source§

impl<S> CheckedResponseGuard<'_, '_, S>

Source

pub const fn status(&self) -> StatusCode

Returns the checked status code.

Source

pub const fn content_type(&self) -> Option<ResponseContentType>

Returns the checked response content type when supplied.

Source

pub const fn rate_limit(&self) -> Option<RateLimit>

Returns validated rate-limit metadata when supplied.

Source

pub fn with_borrowed<R>( &self, inspect: impl for<'response> FnOnce(CheckedResponse<'response>) -> R, ) -> R

Runs a closure with a checked response borrow that cannot escape.

use cloud_sdk::operation::CheckedResponseGuard;
use cloud_sdk::transport::ResponseStorageSanitizer;

fn escape<'guard, S>(
    guard: &'guard CheckedResponseGuard<'_, '_, S>,
) -> &'guard [u8]
where
    S: ResponseStorageSanitizer + ?Sized,
{
    guard.with_borrowed(|response| response.body())
}
Source

pub fn decode_owned<R, E>( self, decode: impl for<'response> FnOnce(CheckedResponse<'response>) -> Result<R, E>, ) -> Result<R, E>

Decodes an owned value, clears all response storage, and then returns.

Trait Implementations§

Source§

impl<S> Debug for CheckedResponseGuard<'_, '_, S>

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'buffer, 'sanitizer, S> !UnwindSafe for CheckedResponseGuard<'buffer, 'sanitizer, S>

§

impl<'buffer, 'sanitizer, S> Freeze for CheckedResponseGuard<'buffer, 'sanitizer, S>
where S: ?Sized,

§

impl<'buffer, 'sanitizer, S> RefUnwindSafe for CheckedResponseGuard<'buffer, 'sanitizer, S>
where S: RefUnwindSafe + ?Sized,

§

impl<'buffer, 'sanitizer, S> Send for CheckedResponseGuard<'buffer, 'sanitizer, S>
where S: Sync + ?Sized,

§

impl<'buffer, 'sanitizer, S> Sync for CheckedResponseGuard<'buffer, 'sanitizer, S>
where S: Sync + ?Sized,

§

impl<'buffer, 'sanitizer, S> Unpin for CheckedResponseGuard<'buffer, 'sanitizer, S>
where S: ?Sized,

§

impl<'buffer, 'sanitizer, S> UnsafeUnpin for CheckedResponseGuard<'buffer, 'sanitizer, S>
where S: ?Sized,

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.