Struct JsonCodec
pub struct JsonCodec;Trait Implementations§
§impl CratestackCodec for JsonCodec
impl CratestackCodec for JsonCodec
§fn encode_into<T>(
&self,
value: &T,
out: &mut Vec<u8>,
) -> Result<(), CratestackError>
fn encode_into<T>( &self, value: &T, out: &mut Vec<u8>, ) -> Result<(), CratestackError>
serde_json writes into any io::Write, so this appends to out
directly instead of the default’s encode-then-copy.
§fn decode<T>(&self, bytes: &[u8]) -> Result<T, CratestackError>where
T: for<'de> Deserialize<'de>,
fn decode<T>(&self, bytes: &[u8]) -> Result<T, CratestackError>where
T: for<'de> Deserialize<'de>,
Same as serde_json::from_slice (including its trailing-data check),
wrapped in serde_path_to_error so the error’s detail names the field
that failed (failed to decode JSON body: amountE8: invalid type ...).
The public message of CratestackError::Codec stays generic; the path
reaches operators through detail() only.
const CONTENT_TYPE: &'static str = "application/json"
fn encode<T>(&self, value: &T) -> Result<Vec<u8>, CratestackError>
Source§impl HttpClientCodec for JsonCodec
Available on crate feature codec-json only.
impl HttpClientCodec for JsonCodec
Available on crate feature
codec-json only.fn accept_header_value(&self) -> &'static str
fn sequence_accept_header_value(&self) -> &'static str
fn decode_response<T>(
&self,
content_type: &str,
body: &[u8],
) -> Result<T, CratestackError>where
T: DeserializeOwned,
fn decode_sequence_response<T>(
&self,
content_type: &str,
body: &[u8],
) -> Result<Vec<T>, CratestackError>where
T: DeserializeOwned,
Source§fn payload_accept(&self) -> &'static str
fn payload_accept(&self) -> &'static str
The response payload types this codec reads inside a COSE
envelope, as a
Cratestack-Payload-Accept value: one to eight
lowercase type/subtype entries joined by ", ", in order of
preference. The default is CONTENT_TYPE
alone, which suits a codec that writes and reads the same type;
override it for an asymmetric one (a form in, JSON out). A sealed
call sends the header only when this is not application/cbor, and
the client refuses any answer sealed under a type it does not list.Auto Trait Implementations§
impl Freeze for JsonCodec
impl RefUnwindSafe for JsonCodec
impl Send for JsonCodec
impl Sync for JsonCodec
impl Unpin for JsonCodec
impl UnsafeUnpin for JsonCodec
impl UnwindSafe for JsonCodec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more