Skip to main content

ReadOnlyContext

Struct ReadOnlyContext 

Source
pub struct ReadOnlyContext<'a>(/* private fields */);
Expand description

Request, response and read-only KV access for one call of a Registry::read_only handler.

Maps cannot be written:

ⓘ
use ccf_app::{EndpointResult, ReadOnlyContext};

fn write_in_read_only_handler(context: &mut ReadOnlyContext<'_>) -> EndpointResult {
    context.map("records").put(b"key", b"value")?;
    Ok(())
}

Implementations§

Source§

impl<'ctx> ReadOnlyContext<'ctx>

Source

pub fn body(&self) -> BridgeResult<&[u8]>

Borrow the raw request body. Copy it before calling a &mut self method if it is still needed.

Source

pub fn query(&self) -> BridgeResult<&str>

Borrow the raw query string, without the leading ? and not percent-decoded.

Source

pub fn path_param(&mut self, name: &str) -> BridgeResult<Option<String>>

Copy the decoded path parameter name, such as "key" for /records/{key}, or None if it is absent.

Source

pub fn header(&mut self, name: &str) -> BridgeResult<Option<Vec<u8>>>

Copy the raw value of the request header name, which must be lowercase, or None if it is absent.

Source

pub fn set_status(&mut self, status: u16) -> BridgeResult<()>

Set the response status. Unknown statuses are rejected with BridgeError::InvalidArgument.

Source

pub fn set_header(&mut self, name: &str, value: &str) -> BridgeResult<()>

Set a response header. Invalid names and values, including any containing CR or LF, are rejected with BridgeError::InvalidArgument.

Source

pub fn set_body(&mut self, body: &[u8]) -> BridgeResult<()>

Set the raw response body.

Source

pub fn map<'a>(&'a mut self, name: &'a str) -> ReadOnlyMap<'a, 'ctx>

Access the map name in this call’s transaction.

Auto Trait Implementations§

§

impl<'a> Freeze for ReadOnlyContext<'a>

§

impl<'a> RefUnwindSafe for ReadOnlyContext<'a>

§

impl<'a> !Send for ReadOnlyContext<'a>

§

impl<'a> !Sync for ReadOnlyContext<'a>

§

impl<'a> Unpin for ReadOnlyContext<'a>

§

impl<'a> UnsafeUnpin for ReadOnlyContext<'a>

§

impl<'a> !UnwindSafe for ReadOnlyContext<'a>

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.