pub struct Context<'ptr, 'req> {
pub session_id: Uuid,
/* private fields */
}
Expand description
Context is a structure that is exposed to the programmer when registering closures as request handlers.
Fields§
§session_id: Uuid
Implementations§
Source§impl<'ptr, 'req> Context<'ptr, 'req>
impl<'ptr, 'req> Context<'ptr, 'req>
pub fn new( request: Rc<RefCell<Request<'req>>>, response: Rc<RefCell<Response<'req>>>, session_id: Uuid, session_manager: Arc<SessionManager>, ) -> Self
Sourcepub fn request_mut(&mut self) -> RefMut<'_, Request<'req>>
pub fn request_mut(&mut self) -> RefMut<'_, Request<'req>>
Mutably borrow the reference to the request. This may be needed for what appears to be a read operation because items like headers and GET parameters are lazily parsed out of the request buffer.
Sourcepub fn response(&self) -> Ref<'_, Response<'req>>
pub fn response(&self) -> Ref<'_, Response<'req>>
Borrow the response that is to be sent back to the client.
Sourcepub fn response_mut(&mut self) -> RefMut<'_, Response<'req>>
pub fn response_mut(&mut self) -> RefMut<'_, Response<'req>>
Mutably borrow the response that is to be sent back to the client.
Sourcepub fn write_session(&self, session_id: Uuid, key: &str, value: &str) -> bool
pub fn write_session(&self, session_id: Uuid, key: &str, value: &str) -> bool
Makes a write to a session with a key and value Returns true if a write happened to a session, false if no session id exists Writing an empty string to this will remove the item from the session storage
Sourcepub fn read_session(&self, session_id: Uuid, key: &str) -> Option<String>
pub fn read_session(&self, session_id: Uuid, key: &str) -> Option<String>
Reads from a session store, the value associated with the key Returns None if the session or the key is nonexistent
Sourcepub fn clear_session(&self, session_id: Uuid)
pub fn clear_session(&self, session_id: Uuid)
Clears the session data of any session ID passed in Shrinks the session data hashmap accordingly
Sourcepub fn delete_session(&self, session_id: Uuid)
pub fn delete_session(&self, session_id: Uuid)
Completely deletes the session storage related to the passed-in session_id value Shrinks the session storage hashmap accordingly
Sourcepub fn new_session(&self) -> Uuid
pub fn new_session(&self) -> Uuid
Creates a new session and returns the session id zero uuid is the default invalid uuid
Sourcepub fn session_exists(&self, session_id: Uuid) -> bool
pub fn session_exists(&self, session_id: Uuid) -> bool
Returns true or false if the session associated with session_id exists
Auto Trait Implementations§
impl<'ptr, 'req> Freeze for Context<'ptr, 'req>
impl<'ptr, 'req> !RefUnwindSafe for Context<'ptr, 'req>
impl<'ptr, 'req> !Send for Context<'ptr, 'req>
impl<'ptr, 'req> !Sync for Context<'ptr, 'req>
impl<'ptr, 'req> Unpin for Context<'ptr, 'req>
impl<'ptr, 'req> !UnwindSafe for Context<'ptr, 'req>
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
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