Skip to main content

Module model

Module model 

Source
Expand description

The JSON envelope types. A view serializes a result as is. The envelope wraps a success or a failure for a reader that wants a status and a schema version: Envelope::Ok holds a result, and Envelope::Err holds an ErrorBody.

View::emit_err writes an Envelope::Err for a failure with no model. The types serialize with the json feature and describe themselves with schema.

use ctl_core::model::{Envelope, ErrorBody, SCHEMA_VERSION};

let failed = Envelope::<()>::err(ErrorBody::new("toy", "no such row"));
assert!(matches!(
    failed,
    Envelope::Err {
        schema_version: SCHEMA_VERSION,
        ..
    }
));

Structs§

ErrorBody
The payload of a failure envelope: which binary failed, and why.

Enums§

Envelope
A JSON envelope: status is ok with data, or err with error, and both carry schema_version.

Constants§

SCHEMA_VERSION
The envelope shape version, written to every envelope as schema_version. ctl-core raises it when the envelope shape changes.