bytes_kman/std/path.rs
1use std::path::PathBuf;
2
3use crate::{TBuffer, TBytes};
4
5impl TBytes for PathBuf {
6 fn size(&self) -> usize {
7 self.as_os_str().to_os_string().size()
8 }
9
10 fn to_bytes(&self) -> Vec<u8> {
11 self.as_os_str().to_os_string().to_bytes()
12 }
13
14 fn from_bytes(buffer: &mut TBuffer) -> Option<Self>
15 where
16 Self: Sized,
17 {
18 let str = std::ffi::OsString::from_bytes(buffer)?;
19 Some(PathBuf::from(str))
20 }
21}