1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#[cfg(feature = "alloc")]
use alloc::vec::Vec;
use crate::SuperError;
pub trait Write {
type Error: SuperError + 'static;
fn write(&mut self, data: &[u8]) -> Result<(), Self::Error>;
}
impl<W: Write + ?Sized> Write for &'_ mut W {
type Error = W::Error;
fn write(&mut self, data: &[u8]) -> Result<(), Self::Error> {
(**self).write(data)
}
}
#[cfg(feature = "alloc")]
impl Write for Vec<u8> {
type Error = core::convert::Infallible;
fn write(&mut self, data: &[u8]) -> Result<(), Self::Error> {
self.extend(data);
Ok(())
}
}