Skip to main content

ModelledError

Trait ModelledError 

Source
pub trait ModelledError:
    Error
    + Send
    + Sync
    + 'static {
    // Required methods
    fn info(&self) -> &'static ErrorInfo;
    fn to_json(&self) -> Value;

    // Provided methods
    fn shape_id(&self) -> &'static str { ... }
    fn write_json_to(&self, out: &mut dyn Write) -> Result<()> { ... }
    fn write_json(
        &self,
        out: &mut Vec<u8>,
    ) -> Result<Vec<(&'static str, String)>> { ... }
}
Expand description

An error shape from the model. Generated for every @error structure.

Required Methods§

Source

fn info(&self) -> &'static ErrorInfo

Source

fn to_json(&self) -> Value

Every member, as on the wire; the protocol moves header members out.

Provided Methods§

Source

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

The model’s shape id, independent of Rust renames.

Source

fn write_json_to(&self, out: &mut dyn Write) -> Result<()>

Writes all fields as a document, including members bound to HTTP headers or payloads in unary responses. Generated errors override this to support bounded stream serialization without an intermediate value.

Source

fn write_json(&self, out: &mut Vec<u8>) -> Result<Vec<(&'static str, String)>>

The body (members plus "__type") straight into out, without the header members, which come back as (header, text). Generated errors write in one pass through [write_error]; this default goes through ModelledError::to_json.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§