Skip to main content

View

Trait View 

Source
pub trait View: Send + Sync {
    // Required methods
    fn route(&self) -> &'static str;
    fn heading(&self) -> &'static str;
    fn listed(&self) -> bool;
    fn param_keys(&self, ctx: &Context) -> Result<Vec<String>, ApiError>;
    fn handle_get(
        &self,
        query: &BTreeMap<String, String>,
        ctx: &Context,
    ) -> Result<String, ApiError>;
    fn handle_action(
        &self,
        name: &str,
        query: &BTreeMap<String, String>,
        body: &str,
        ctx: &Context,
    ) -> Result<String, ApiError>;
}
Expand description

The object-safe façade the router dispatches through, as crate::Table is for tables. A blanket implementation covers every ViewLogic, so nothing outside this module implements it.

Required Methods§

Source

fn route(&self) -> &'static str

The route segment, from ViewLogic::name.

Source

fn heading(&self) -> &'static str

The shell’s heading, from ViewLogic::title.

Source

fn listed(&self) -> bool

Whether the switcher lists this view, from ViewLogic::in_switcher.

Source

fn param_keys(&self, ctx: &Context) -> Result<Vec<String>, ApiError>

The keys of the parameters this view declares, which the server checks against the ones the address itself uses.

Source

fn handle_get( &self, query: &BTreeMap<String, String>, ctx: &Context, ) -> Result<String, ApiError>

GET /api/views/<view>: the parameters, what they resolved to, and the page rendered from them.

Source

fn handle_action( &self, name: &str, query: &BTreeMap<String, String>, body: &str, ctx: &Context, ) -> Result<String, ApiError>

POST /api/views/<view>/actions/<name>: write what the form asks for, and answer with the sentence saying so.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<V: ViewLogic> View for V