Struct Context

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

Source

pub fn new( request: Rc<RefCell<Request<'req>>>, response: Rc<RefCell<Response<'req>>>, session_id: Uuid, session_manager: Arc<SessionManager>, ) -> Self

Source

pub fn request(&self) -> Ref<'_, Request<'req>>

Borrow the reference to the request.

Source

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.

Source

pub fn response(&self) -> Ref<'_, Response<'req>>

Borrow the response that is to be sent back to the client.

Source

pub fn response_mut(&mut self) -> RefMut<'_, Response<'req>>

Mutably borrow the response that is to be sent back to the client.

Source

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

Source

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

Source

pub fn clear_session(&self, session_id: Uuid)

Clears the session data of any session ID passed in Shrinks the session data hashmap accordingly

Source

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

Source

pub fn new_session(&self) -> Uuid

Creates a new session and returns the session id zero uuid is the default invalid uuid

Source

pub fn session_exists(&self, session_id: Uuid) -> bool

Returns true or false if the session associated with session_id exists

Source

pub fn redirect(&mut self, location: &str)

Sets the response code and location header

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> 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> 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, 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V