Skip to main content

Table

Trait Table 

Source
pub trait Table: Send + Sync {
    // Required methods
    fn route(&self) -> &'static str;
    fn heading(&self) -> &'static str;
    fn data_file(&self) -> &'static str;
    fn handle_get(&self, ctx: &Context) -> Result<String, ApiError>;
    fn handle_put(&self, ctx: &Context, body: &str) -> Result<String, ApiError>;
    fn handle_derive(
        &self,
        ctx: &Context,
        body: &str,
    ) -> Result<String, ApiError>;
}
Expand description

The object-safe façade the router holds. Each method returns the JSON body of one endpoint.

Required Methods§

Source

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

The route segment, from TableLogic::name.

Source

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

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

Source

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

The file under Data/, from TableLogic::file.

Source

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

GET /api/<table>: the schema, the stored rows, their derivation, their validation errors, and any sibling data.

Source

fn handle_put(&self, ctx: &Context, body: &str) -> Result<String, ApiError>

PUT /api/<table>: write the posted rows, then return the derivation of what was written.

Source

fn handle_derive(&self, ctx: &Context, body: &str) -> Result<String, ApiError>

POST /api/<table>/derive: derive and validate the posted rows without writing.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<T: TableLogic> Table for T