pub struct FilePath<'f>(Cow<'f, CStr>);
Expand description
File name represented as a nul-terminated byte array.
While zvariant::Type
and serde::{Serialize, Deserialize}
, are implemented for Path
and
PathBuf
, unfortunately serde
serializes them as UTF-8 strings and that limits the number
of possible characters to use on a file path. This is not the desired behavior since file paths
are not guaranteed to contain only UTF-8 characters.
To solve this problem, this type is provided which encodes the underlying file path as a null-terminated byte array.
§Examples:
use zvariant::FilePath;
use std::path::{Path, PathBuf};
let path = Path::new("/hello/world\0");
let path_buf = PathBuf::from(path);
let p1 = FilePath::from(path);
let p2 = FilePath::from(path_buf);
let p3 = FilePath::from("/hello/world");
assert_eq!(p1, p2);
assert_eq!(p2, p3);
Tuple Fields§
§0: Cow<'f, CStr>
Implementations§
Trait Implementations§
Source§impl<'de, 'f> Deserialize<'de> for FilePath<'f>
impl<'de, 'f> Deserialize<'de> for FilePath<'f>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'f> Ord for FilePath<'f>
impl<'f> Ord for FilePath<'f>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<'f> PartialOrd for FilePath<'f>
impl<'f> PartialOrd for FilePath<'f>
impl<'f> Eq for FilePath<'f>
impl<'f> StructuralPartialEq for FilePath<'f>
Auto Trait Implementations§
impl<'f> Freeze for FilePath<'f>
impl<'f> RefUnwindSafe for FilePath<'f>
impl<'f> Send for FilePath<'f>
impl<'f> Sync for FilePath<'f>
impl<'f> Unpin for FilePath<'f>
impl<'f> UnwindSafe for FilePath<'f>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<'de, T> DynamicDeserialize<'de> for Twhere
T: Type + Deserialize<'de>,
impl<'de, T> DynamicDeserialize<'de> for Twhere
T: Type + Deserialize<'de>,
Source§type Deserializer = PhantomData<T>
type Deserializer = PhantomData<T>
A DeserializeSeed implementation for this type.
Source§fn deserializer_for_signature(
signature: &Signature,
) -> Result<<T as DynamicDeserialize<'de>>::Deserializer, Error>
fn deserializer_for_signature( signature: &Signature, ) -> Result<<T as DynamicDeserialize<'de>>::Deserializer, Error>
Get a deserializer compatible with this parsed signature.