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§
Provided Methods§
Sourcefn write_json_to(&self, out: &mut dyn Write) -> Result<()>
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.
Sourcefn write_json(&self, out: &mut Vec<u8>) -> Result<Vec<(&'static str, String)>>
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".