pub struct Ucs2LeVec(/* private fields */);
Expand description
Wrapper around Vec<u8>
containing a valid null-terminated UCS-2 LE string.
This type is not FFI compatible with *const u16
!
Because Ucs2LeVec
uses a [u8]
as the backing data type (as opposed to a
[u16]
), the data is not guaranteed to be u16
aligned!
DEVNOTE: While we want Ucs2LeSlice
to be backed by a [u8]
, Ucs2LeVec
should likely get switched over to a Vec<u16>
, so we can get proper u16
alignment. Note that in this case, we could use a bit of (trivially save)
unsafe
code to impl Deref<Target = Ucs2LeSlice>
by reinterpretting the
Vec<u16>
as a &[u8]
, so there wouldn’t be any major ergonomic hit.
Implementations§
Source§impl Ucs2LeVec
impl Ucs2LeVec
Sourcepub fn from_vec_with_nul(buf: Vec<u8>) -> Result<Ucs2LeVec, Ucs2ParseError>
pub fn from_vec_with_nul(buf: Vec<u8>) -> Result<Ucs2LeVec, Ucs2ParseError>
Validate that the provided Vec<u8>
is a valid null-terminated UCS-2 LE
string, truncating the slice to the position of the first null u16.
Sourcepub fn into_inner(self) -> Vec<u8>
pub fn into_inner(self) -> Vec<u8>
Consume self, returning the underlying raw Vec<u8>