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 param_keys(&self, ctx: &Context) -> Result<Vec<String>, ApiError>;
    fn handle_get(
        &self,
        query: &BTreeMap<String, String>,
        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 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 sections rendered from them.

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