Struct Immortal

Source
pub struct Immortal { /* private fields */ }
Expand description

Immortal middleware and routing configuration, as well as the session manager.

Implementations§

Source§

impl Immortal

Source

pub fn new() -> Self

Construct a new Immortal server

Source

pub fn listen<S>(&self, socket_addr: S) -> Result<(), ImmortalError<'_>>
where S: Into<SocketAddr>,

Listens for incoming connections, with as many threads as the system has available for parallelism

Source

pub fn listen_with<S>( &self, socket_addr: S, thread_count: usize, ) -> Result<(), ImmortalError<'_>>
where S: Into<SocketAddr>,

Listens for incoming connections using a specific amount of threads

If threading feature is not present, thread_count will be ignored

Source

pub fn process_buffer(&mut self, request_buffer: &[u8]) -> Vec<u8>

Pass a buffer through the HTTP implementation without listening on a port or dispatching tasks to threads.

Source

pub fn add_middleware(&mut self, func: Handler)

Adds middleware that gets executed just before the router.

if a middleware handler produces a redirect, all of the following middleware handlers are skipped and the redirect is yielded, if middleware produces a redirect, the router is bypassed and custom routes do not run.

Source

pub fn register(&mut self, method: &str, route: &str, func: Handler) -> bool

Calls into the router to register a function Returns true if a route was registered

Source

pub fn unregister(&mut self, method: &str, route: &str) -> bool

Calls into the router to unregister a function Returns true if a route was unregistered

Source

pub fn fallback(&mut self, func: Handler)

Registers the fallback function for when a request is not caught by the router or for if you want to handle all requests manually

Source

pub fn set_session_duration(&self, duration: Duration)

sets the maximum duration that a session may be allowed to persist for regardless of inactivity

Source

pub fn set_inactive_duration(&self, duration: Duration)

Sets the server-side session inactivity expiry duration

Source

pub fn set_prune_rate(&self, duration: Duration)

Sets the prune rate for sessions, will attempt to prune old sessions every duration

Source

pub fn disable_sessions(&mut self)

Configures sessions to be disabled, clears existing server-side sessions

Source

pub fn enable_sessions(&mut self)

Configures sessions to be enabled

Trait Implementations§

Source§

impl Default for Immortal

Source§

fn default() -> Immortal

Returns the “default value” for a type. Read more
Source§

impl Drop for Immortal

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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