sqlx_core_oldapi/io/
decode.rs

1use bytes::Bytes;
2
3use crate::error::Error;
4
5pub trait Decode<'de, Context = ()>
6where
7    Self: Sized,
8{
9    fn decode(buf: Bytes) -> Result<Self, Error>
10    where
11        Self: Decode<'de, ()>,
12    {
13        Self::decode_with(buf, ())
14    }
15
16    fn decode_with(buf: Bytes, context: Context) -> Result<Self, Error>;
17}
18
19impl Decode<'_> for Bytes {
20    fn decode_with(buf: Bytes, _: ()) -> Result<Self, Error> {
21        Ok(buf)
22    }
23}
24
25impl Decode<'_> for () {
26    fn decode_with(_: Bytes, _: ()) -> Result<(), Error> {
27        Ok(())
28    }
29}