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>
Methods from Deref<Target = Ucs2LeSlice>§
sourcepub fn as_bytes_without_nul(&self) -> &[u8] ⓘ
pub fn as_bytes_without_nul(&self) -> &[u8] ⓘ
View the underlying data as raw bytes, without the trailing null u16
.
sourcepub fn to_ucs2_le_vec(&self) -> Ucs2LeVec
pub fn to_ucs2_le_vec(&self) -> Ucs2LeVec
Copies self
into a new Ucs2LeVec
.
Trait Implementations§
source§impl AsRef<Ucs2LeSlice> for Ucs2LeVec
impl AsRef<Ucs2LeSlice> for Ucs2LeVec
source§fn as_ref(&self) -> &Ucs2LeSlice
fn as_ref(&self) -> &Ucs2LeSlice
source§impl Borrow<Ucs2LeSlice> for Ucs2LeVec
impl Borrow<Ucs2LeSlice> for Ucs2LeVec
source§fn borrow(&self) -> &Ucs2LeSlice
fn borrow(&self) -> &Ucs2LeSlice
source§impl DefaultEncoding for Ucs2LeVec
impl DefaultEncoding for Ucs2LeVec
source§type Encoding = TableEncoder
type Encoding = TableEncoder
source§impl Deref for Ucs2LeVec
impl Deref for Ucs2LeVec
source§type Target = Ucs2LeSlice
type Target = Ucs2LeSlice
source§fn deref(&self) -> &Ucs2LeSlice
fn deref(&self) -> &Ucs2LeSlice
source§impl Ord for Ucs2LeVec
impl Ord for Ucs2LeVec
source§impl PartialOrd for Ucs2LeVec
impl PartialOrd for Ucs2LeVec
source§impl<'encoding, AnyR: 'static> StructDecodeMetadata<'encoding, AnyR> for Ucs2LeVec
impl<'encoding, AnyR: 'static> StructDecodeMetadata<'encoding, AnyR> for Ucs2LeVec
source§const DECODERS: &'static [ErasedDecoderEntry] = _
const DECODERS: &'static [ErasedDecoderEntry] = _
source§impl<AnyR: 'static> StructEncodeMetadata<AnyR> for Ucs2LeVec
impl<AnyR: 'static> StructEncodeMetadata<AnyR> for Ucs2LeVec
source§const ENCODERS: &'static [ErasedEncoderEntry] = _
const ENCODERS: &'static [ErasedEncoderEntry] = _
source§impl StructMetadata for Ucs2LeVec
impl StructMetadata for Ucs2LeVec
impl Downcast<Ucs2LeVec> for Ucs2LeVec
impl Eq for Ucs2LeVec
impl StructuralPartialEq for Ucs2LeVec
Auto Trait Implementations§
impl Freeze for Ucs2LeVec
impl RefUnwindSafe for Ucs2LeVec
impl Send for Ucs2LeVec
impl Sync for Ucs2LeVec
impl Unpin for Ucs2LeVec
impl UnwindSafe for Ucs2LeVec
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> Protobuf for Twhere
T: DefaultEncoding,
<T as DefaultEncoding>::Encoding: MessageEncode<T, NoResources> + for<'a> MessageDecode<'a, T, NoResources> + FieldEncode<T, NoResources> + for<'a> FieldDecode<'a, T, NoResources>,
impl<T> Protobuf for Twhere
T: DefaultEncoding,
<T as DefaultEncoding>::Encoding: MessageEncode<T, NoResources> + for<'a> MessageDecode<'a, T, NoResources> + FieldEncode<T, NoResources> + for<'a> FieldDecode<'a, T, NoResources>,
source§type Encoding = <T as DefaultEncoding>::Encoding
type Encoding = <T as DefaultEncoding>::Encoding
Self
.