#[repr(C)]pub struct TarFormatString<const N: usize> { /* private fields */ }
Expand description
Base type for strings embedded in a Tar header. The length depends on the
context. The returned string is likely to be UTF-8/ASCII, which is verified
by getters, such as TarFormatString::as_str
.
An optionally null terminated string. The contents are either:
- A fully populated string with no null termination or
- A partially populated string where the unused bytes are zero.
Implementations§
Source§impl<const N: usize> TarFormatString<N>
A Tar format string is a fixed length byte array containing UTF-8 bytes.
This string will be null terminated if it doesn’t fill the entire array.
impl<const N: usize> TarFormatString<N>
A Tar format string is a fixed length byte array containing UTF-8 bytes. This string will be null terminated if it doesn’t fill the entire array.
Sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Returns the length of the payload in bytes. This is either the full
capacity N
or the data until the first NULL byte.
Sourcepub fn as_str(&self) -> Result<&str, Utf8Error>
pub fn as_str(&self) -> Result<&str, Utf8Error>
Returns a str ref without terminating or intermediate NULL bytes. The string is truncated at the first NULL byte, in case not the full length was used.
Sourcepub fn as_str_until_first_space(&self) -> Result<&str, Utf8Error>
pub fn as_str_until_first_space(&self) -> Result<&str, Utf8Error>
Wrapper around Self::as_str
that stops as soon as the first space
is found. This is necessary to properly parse certain Tar-style encoded
numbers. Some ustar implementations pad spaces which prevents the proper
parsing as number.
Sourcepub fn append<const S: usize>(&mut self, other: &TarFormatString<S>)
pub fn append<const S: usize>(&mut self, other: &TarFormatString<S>)
Append to end of string. Panics if there is not enough capacity.
Trait Implementations§
Source§impl<const N: usize> Clone for TarFormatString<N>
impl<const N: usize> Clone for TarFormatString<N>
Source§fn clone(&self) -> TarFormatString<N>
fn clone(&self) -> TarFormatString<N>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more