bytes_kman/std/
mutex.rs

1use crate::{TBuffer, TBytes};
2
3impl<T: TBytes> TBytes for std::sync::Mutex<T> {
4    fn size(&self) -> usize {
5        self.lock().unwrap().size()
6    }
7
8    fn to_bytes(&self) -> Vec<u8> {
9        self.lock().unwrap().to_bytes()
10    }
11
12    fn from_bytes(buffer: &mut TBuffer) -> Option<Self>
13    where
14        Self: Sized,
15    {
16        Some(std::sync::Mutex::new(T::from_bytes(buffer)?))
17    }
18}