Struct Action

Source
pub struct Action {
    pub request: Request,
    pub response: Response,
    pub session: Session,
    pub salt: Arc<String>,
    pub module: String,
    pub class: String,
    pub action: String,
    pub param: Option<String>,
    pub cache: Cache,
    pub db: Arc<DB>,
    pub internal: bool,
    pub tool: Tool,
    /* private fields */
}
Expand description

Main struct to run web engine

§Values

  • request: Request - Request from web server.
  • response: Response - Response to web server.
  • session: Session - Session data.
  • salt: Arc<String> - Secret salt.
  • data: BTreeMap<i64, Data> - Data transferred between controllers template markers and cache.
  • pub module: String - Start module name.
  • pub class: String - Start class name.
  • pub action: String - Start action (controller) name.
  • param: Option<String> - Start param.
  • module_id: i64 - Module ID.
  • class_id: i64, - Class ID.
  • action_id: i64 - Action ID.
  • current_module_id: i64 - Current module ID.
  • current_class_id: i64 - Current class ID.
  • html: Option<Arc<BTreeMap<i64, Vec<Node>>>> - Current templates.
  • lang: Option<Arc<BTreeMap<i64, String>>> - Current translates.
  • engine: Arc<ActMap> - Engine of server.
  • language: Arc<Lang> - All translates.
  • template: Arc<Html> - All templates.
  • cache: Arc<Mutex<Cache>> - Cache.
  • db: Arc<DB> - Database pool.
  • mail: Arc<Mail> - Mail function.
  • internal: bool - Internal call of controller.

Fields§

§request: Request

Request from web server

§response: Response

Response to web server

§session: Session

Session data

§salt: Arc<String>

Secret salt

§module: String

Start module name

§class: String

Start class name

§action: String

Start action (controller) name

§param: Option<String>

Start param

§cache: Cache

Cache

§db: Arc<DB>

Database pool

§internal: bool

Internal call of controller

§tool: Tool

Different features

Implementations§

Source§

impl Action

Source

pub async fn load( &mut self, key: impl StrOrI64, module: impl StrOrI64, class: impl StrOrI64, action: impl StrOrI64, param: Option<String>, )

Load internal controller

Source

pub fn lang(&self, text: impl StrOrI64) -> String

Get translate

Source

pub async fn lang_current(&self) -> Arc<LangItem>

Get current lang

Source

pub async fn lang_list(&self) -> Arc<Vec<Arc<LangItem>>>

Get vector of system languages

Source

pub async fn all_lang_list(&self) -> Vec<LangItem>

Get vector of all languages

Source

pub fn set<T>(&mut self, key: impl StrOrI64, value: T)
where T: Into<Data>,

Setting data into internal memory

Source

pub fn get<T>(&self, key: impl StrOrI64) -> Option<&T>
where for<'a> &'a T: From<&'a Data>,

Getting references to data from internal memory

Source

pub fn take<T>(&mut self, key: impl StrOrI64) -> Option<T>
where T: From<Data>,

Taking (removing) data from internal memory

Source

pub fn set_flash(&mut self, kind: Flash, value: String)

Set flash message to session data

Source

pub fn take_flash(&mut self) -> Option<Vec<(Flash, String)>>

Take flash message from session data

Source

pub fn set_lang(&mut self, key: impl StrOrI64)

Set value for the template from translate

Source

pub fn set_lang_arr(&mut self, keys: &[impl StrOrI64])

Set an array of values for the template from the translation

Source

pub fn spawn<F>(&self, future: F) -> JoinHandle<F::Output>
where F: Future + Send + 'static, F::Output: Send + 'static,

Spawns a new asynchronous task, returning a tokio::task::JoinHandle for it.

The provided future will start running in the background immediately when spawn is called, even if you don’t await the returned JoinHandle.

Source

pub async fn write(&mut self, answer: Answer)

Write data to the output stream

Source

pub async fn get_access( &mut self, module: impl StrOrI64, class: impl StrOrI64, action: impl StrOrI64, ) -> bool

Get access to run controller

Source

pub fn render(&mut self, template: impl StrOrI64) -> Answer

Render template

§Value
  • template: &str - Name of template
Source

pub async fn route( &mut self, module: &str, class: &str, action: &str, param: Option<&str>, lang_id: Option<i64>, ) -> String

Get route

Source

pub async fn mail(&self, message: MailMessage) -> bool

Send email

Source

pub fn percent_decode<'a>( &self, url: &'a str, ) -> Result<Cow<'a, str>, Utf8Error>

Percent decode url

Source

pub async fn not_found(&mut self) -> String

Get not_found url

Trait Implementations§

Source§

impl Debug for Action

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Action

§

impl !RefUnwindSafe for Action

§

impl Send for Action

§

impl Sync for Action

§

impl Unpin for Action

§

impl !UnwindSafe for Action

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> Chain<T> for T

Source§

fn len(&self) -> usize

The number of items that this chain link consists of.
Source§

fn append_to(self, v: &mut Vec<T>)

Append the elements in this link to the chain.
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> Same for T

Source§

type Output = T

Should always be Self
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

Source§

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