Crate [`InOutBufReserved`] from a single mutable slice. # Errors If `out` is too small.
(buf: &'a mut [T], msg_len: usize)
| 26 | /// # Errors |
| 27 | /// If `out` is too small. |
| 28 | pub fn from_mut_slice(buf: &'a mut [T], msg_len: usize) -> Result<Self, OutIsTooSmallError> { |
| 29 | if msg_len > buf.len() { |
| 30 | return Err(OutIsTooSmallError); |
| 31 | } |
| 32 | let p = buf.as_mut_ptr(); |
| 33 | let out_len = buf.len(); |
| 34 | Ok(Self { |
| 35 | in_ptr: p, |
| 36 | out_ptr: p, |
| 37 | in_len: msg_len, |
| 38 | out_len, |
| 39 | _pd: PhantomData, |
| 40 | }) |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | impl<T> InOutBufReserved<'_, '_, T> { |