pub struct FsStr { /* private fields */ }
Expand description
Borrowed reference to an VEXos filesystem OS string.
This type represents a borrowed reference to a string in VEXos’s preferred representation for filesystem paths.
Implementations§
Source§impl FsStr
impl FsStr
Sourcepub const unsafe fn from_encoded_bytes_unchecked(bytes: &[u8]) -> &Self
pub const unsafe fn from_encoded_bytes_unchecked(bytes: &[u8]) -> &Self
Converts a slice of bytes to an FS string slice without checking that the string contains
valid FsStr
-encoded data.
§Safety
As the encoding is unspecified, callers must pass in bytes that originated as a mixture of
validated UTF-8 and bytes from FsStr::as_encoded_bytes
from within the same Rust version
built for the same target platform.
Due to the encoding being self-synchronizing, the bytes from FsStr::as_encoded_bytes
can be
split either immediately before or immediately after any valid non-empty UTF-8 substring.
Sourcepub const fn as_encoded_bytes(&self) -> &[u8]
pub const fn as_encoded_bytes(&self) -> &[u8]
Converts an FS string slice to a byte slice. To convert the byte slice back into an FS
string slice, use the FsStr::from_encoded_bytes_unchecked
function.
§Note
As the encoding is unspecified, any sub-slice of bytes that is not valid UTF-8 should be treated as opaque and only comparable within the same Rust version built for the same target platform. For example, sending the slice over the network or storing it in a file will likely result in incompatible byte slices.
Sourcepub fn to_fs_string(&self) -> FsString
pub fn to_fs_string(&self) -> FsString
Sourcepub fn to_string_lossy(&self) -> Cow<'_, str>
pub fn to_string_lossy(&self) -> Cow<'_, str>
Converts an FsStr
into a UTF-8 encoded string.
Any non-UTF-8 sequences are replaced with the unicode
U+FFFD REPLACEMENT CHARACTER
.