pub struct ApiContext { /* private fields */ }Expand description
Request context passed to API route handlers.
Implementations§
Source§impl ApiContext
impl ApiContext
Sourcepub fn connection_id(&self) -> &str
pub fn connection_id(&self) -> &str
Returns the logical connection id for the current client.
Sourcepub fn peer_addr(&self) -> Option<SocketAddr>
pub fn peer_addr(&self) -> Option<SocketAddr>
Returns the peer socket address when available.
Sourcepub fn request_id(&self) -> &str
pub fn request_id(&self) -> &str
Returns the request correlation id.
Sourcepub fn require_param(&self, key: &str) -> Result<&Value, ApiError>
pub fn require_param(&self, key: &str) -> Result<&Value, ApiError>
Looks up a required parameter or returns a bad request error.
Sourcepub fn bind<T>(&self) -> Result<T, ApiError>where
T: DeserializeOwned,
pub fn bind<T>(&self) -> Result<T, ApiError>where
T: DeserializeOwned,
Binds the raw params payload into a strongly typed value.
Sourcepub fn bind_and_validate<T>(&self) -> Result<T, ApiError>where
T: DeserializeOwned + ValidateParams,
pub fn bind_and_validate<T>(&self) -> Result<T, ApiError>where
T: DeserializeOwned + ValidateParams,
Binds params and runs ValidateParams on the result.
Sourcepub fn bind_validated<T>(&self) -> Result<T, ApiError>where
T: DeserializeOwned + Validate,
pub fn bind_validated<T>(&self) -> Result<T, ApiError>where
T: DeserializeOwned + Validate,
Binds params and runs validator::Validate on the result.
Sourcepub fn attachments(&self) -> &[FileAttachment]
pub fn attachments(&self) -> &[FileAttachment]
Returns all attachments that accompanied the request.
Sourcepub fn server(&self) -> &ServerHandle
pub fn server(&self) -> &ServerHandle
Returns a server handle for outbound event operations.
Sourcepub fn attachment_summaries(&self) -> Vec<Value>
pub fn attachment_summaries(&self) -> Vec<Value>
Returns a simplified JSON view of incoming attachments.
Trait Implementations§
Source§impl Clone for ApiContext
impl Clone for ApiContext
Source§fn clone(&self) -> ApiContext
fn clone(&self) -> ApiContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ApiContext
impl !RefUnwindSafe for ApiContext
impl Send for ApiContext
impl Sync for ApiContext
impl Unpin for ApiContext
impl UnsafeUnpin for ApiContext
impl !UnwindSafe for ApiContext
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
Mutably borrows from an owned value. Read more