Struct App

Source
pub struct App<S = ()> { /* private fields */ }
Expand description

🖥️ A Fluffer App

§Defaults

  • Key: ./key.pem
  • Cert: ./cert.pem
  • Address: 127.0.0.1:1965 (or the ADDRESS environment variable)
App::default()
    .route("/", |_| async { "Hello :>" })
    .run()

Implementations§

Source§

impl<S> App<S>
where S: Send + Sync + Clone + 'static,

Source

pub fn route( self, path: &str, func: impl GemCall<S> + 'static + Sync + Send, ) -> Self

Takes a generic function that implements GemCall, and boxes it into our routes hashmap.

Will panic if an insert error occurs.

Source

pub fn not_found(self, message: impl Into<String>) -> Self

Update the message displayed when a page isn’t found.

Source

pub fn address(self, addr: impl Into<String>) -> Self

Update the server’s address.

Source

pub fn path_to_cert(self, path: impl Into<PathBuf>) -> Self

Update certificate path.

Source

pub fn path_to_key(self, path: impl Into<PathBuf>) -> Self

Update key path.

Source

pub fn titan( self, path: &str, func: impl GemCall<S> + 'static + Sync + Send, max_size: usize, ) -> Self

The same as App::route, but with titan enabled.

When the request’s content exceeds max_size, a PermanentFailure is met.

Set max_size to 0 to disable this behaviour.

Will panic if an insert error occurs.

Source

pub fn state<T: Send + Sync + Clone>(self, state: T) -> App<T>

Replace App’s unit state with State.

Source

pub async fn run(self) -> Result<(), AppErr>

Trait Implementations§

Source§

impl Default for App<()>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<S = ()> !Freeze for App<S>

§

impl<S = ()> !RefUnwindSafe for App<S>

§

impl<S> Send for App<S>
where S: Send,

§

impl<S> Sync for App<S>
where S: Sync,

§

impl<S> Unpin for App<S>
where S: Unpin,

§

impl<S = ()> !UnwindSafe for App<S>

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

impl<T> ErasedDestructor for T
where T: 'static,