pub enum PlatformString {
Unix(Vec<u8>),
WindowsUtf16Le(Vec<u8>),
}Expand description
Represents a platform-native string in an interoperable on-disk form.
This type is intended for forensic preservation of path-bearing values such
as file names or symlink targets. In contrast to String, it does not
require UTF-8 and preserves the original encoded bytes exactly.
Encoding variants:
PlatformString::Unix: raw Unix pathname bytesPlatformString::WindowsUtf16Le: raw bytes interpreted as UTF-16 little-endian
The stored bytes are preserved exactly during encoding/decoding, even if they
are malformed for the declared encoding. Validation is only performed by
explicit conversion helpers such as PlatformString::to_string_strict.
§Serde behavior
When the serde feature is enabled, PlatformString values that are
serialized through higher-level structures may be emitted in a lossy,
human-readable form. This is intentional:
- binary zff encoding/decoding remains lossless
- serde output is intended for display/export formats such as JSON or TOML
- serde serialization must not be relied upon for forensic preservation
In other words:
ValueEncoder/ValueDecoder: exact byte-preserving representationserde::Serialize: human-readable representation, potentially lossy
§Display behavior
Display uses a lossy conversion and is intended only for
human-readable output, not for forensic round-tripping.
Variants§
Unix(Vec<u8>)
Raw bytes interpreted as UTF-8
WindowsUtf16Le(Vec<u8>)
Raw bytes interpreted as UTF-16 little-endian.
Implementations§
Source§impl PlatformString
impl PlatformString
Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
Byte representation of the appropriate PlatformString. Does not contain the encoding information.
Sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
Byte representation of the appropriate PlatformString. Does not contain the encoding information.
Sourcepub fn to_string_strict(&self) -> Result<String>
pub fn to_string_strict(&self) -> Result<String>
Ensures that the Result is a UTF-8 valid string. Fails if the string does contain invalid UTF-8 characters.
Sourcepub fn to_string_lossy(&self) -> String
pub fn to_string_lossy(&self) -> String
Lossy conversation to String. Note: This conversion is lossy and only intended only for human-readable output, not for forensic round-tripping.
Trait Implementations§
Source§impl Clone for PlatformString
impl Clone for PlatformString
Source§fn clone(&self) -> PlatformString
fn clone(&self) -> PlatformString
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PlatformString
impl Debug for PlatformString
Source§impl Display for PlatformString
impl Display for PlatformString
impl Eq for PlatformString
Source§impl From<&OsStr> for PlatformString
Available on target_family=unix only.
impl From<&OsStr> for PlatformString
target_family=unix only.Source§impl From<OsString> for PlatformString
Available on target_family=unix only.
impl From<OsString> for PlatformString
target_family=unix only.Source§impl Hash for PlatformString
impl Hash for PlatformString
Source§impl Ord for PlatformString
impl Ord for PlatformString
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for PlatformString
impl PartialEq for PlatformString
Source§impl PartialOrd for PlatformString
impl PartialOrd for PlatformString
impl StructuralPartialEq for PlatformString
Source§impl TryFrom<&PlatformString> for OsString
Available on target_family=unix only.
impl TryFrom<&PlatformString> for OsString
target_family=unix only.Source§impl ValueDecoder for PlatformString
impl ValueDecoder for PlatformString
Source§type Item = PlatformString
type Item = PlatformString
Source§fn decode_directly<R: Read>(data: &mut R) -> Result<Self::Item>
fn decode_directly<R: Read>(data: &mut R) -> Result<Self::Item>
Source§fn check_key_on_position<K: Into<String>, R: Read>(data: &mut R, key: K) -> bool
fn check_key_on_position<K: Into<String>, R: Read>(data: &mut R, key: K) -> bool
Source§impl ValueEncoder for PlatformString
impl ValueEncoder for PlatformString
Source§fn identifier(&self) -> u8
fn identifier(&self) -> u8
Source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
Auto Trait Implementations§
impl Freeze for PlatformString
impl RefUnwindSafe for PlatformString
impl Send for PlatformString
impl Sync for PlatformString
impl Unpin for PlatformString
impl UnsafeUnpin for PlatformString
impl UnwindSafe for PlatformString
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more