sqlx_core/io/
encode.rs

1pub trait ProtocolEncode<'en, Context = ()> {
2    fn encode(&self, buf: &mut Vec<u8>) -> Result<(), crate::Error>
3    where
4        Self: ProtocolEncode<'en, ()>,
5    {
6        self.encode_with(buf, ())
7    }
8
9    fn encode_with(&self, buf: &mut Vec<u8>, context: Context) -> Result<(), crate::Error>;
10}
11
12impl<'en, C> ProtocolEncode<'en, C> for &'_ [u8] {
13    fn encode_with(&self, buf: &mut Vec<u8>, _context: C) -> Result<(), crate::Error> {
14        buf.extend_from_slice(self);
15        Ok(())
16    }
17}