[−][src]Struct binread::NullWideString
A null terminated UTF-16 string designed to make reading any 16 bit wide null-terminated data easier.
Note: Does not include the null.
Note: This is endian dependent on a per-character basis. Will read u16
s until a 0u16
is found.
Methods
impl NullWideString
[src]
pub fn into_string(self) -> String
[src]
pub fn into_string_lossless(self) -> Result<String, FromUtf16Error>
[src]
Methods from Deref<Target = Vec<u16>>
pub fn capacity(&self) -> usize
1.0.0[src]
Returns the number of elements the vector can hold without reallocating.
Examples
let vec: Vec<i32> = Vec::with_capacity(10); assert_eq!(vec.capacity(), 10);
pub fn as_slice(&self) -> &[T]
1.7.0[src]
Extracts a slice containing the entire vector.
Equivalent to &s[..]
.
Examples
use std::io::{self, Write}; let buffer = vec![1, 2, 3, 5, 8]; io::sink().write(buffer.as_slice()).unwrap();
pub fn as_ptr(&self) -> *const T
1.37.0[src]
Returns a raw pointer to the vector's buffer.
The caller must ensure that the vector outlives the pointer this function returns, or else it will end up pointing to garbage. Modifying the vector may cause its buffer to be reallocated, which would also make any pointers to it invalid.
The caller must also ensure that the memory the pointer (non-transitively) points to
is never written to (except inside an UnsafeCell
) using this pointer or any pointer
derived from it. If you need to mutate the contents of the slice, use as_mut_ptr
.
Examples
let x = vec![1, 2, 4]; let x_ptr = x.as_ptr(); unsafe { for i in 0..x.len() { assert_eq!(*x_ptr.add(i), 1 << i); } }
pub fn len(&self) -> usize
1.0.0[src]
Returns the number of elements in the vector, also referred to as its 'length'.
Examples
let a = vec![1, 2, 3]; assert_eq!(a.len(), 3);
pub fn is_empty(&self) -> bool
1.0.0[src]
Returns true
if the vector contains no elements.
Examples
let mut v = Vec::new(); assert!(v.is_empty()); v.push(1); assert!(!v.is_empty());
Trait Implementations
impl BinRead for NullWideString
[src]
type Args = ()
The type of arguments needed to be supplied in order to read this type, usually a tuple. Read more
fn read_options<R: Read + Seek>(
reader: &mut R,
options: &ReadOptions,
args: Self::Args
) -> BinResult<Self>
[src]
reader: &mut R,
options: &ReadOptions,
args: Self::Args
) -> BinResult<Self>
fn read<R: Read + Seek>(reader: &mut R) -> BinResult<Self>
[src]
fn read_args<R: Read + Seek>(
reader: &mut R,
args: Self::Args
) -> BinResult<Self>
[src]
reader: &mut R,
args: Self::Args
) -> BinResult<Self>
fn after_parse<R: Read + Seek>(
&mut self,
_: &mut R,
_: &ReadOptions,
_: Self::Args
) -> BinResult<()>
[src]
&mut self,
_: &mut R,
_: &ReadOptions,
_: Self::Args
) -> BinResult<()>
fn args_default() -> Option<Self::Args>
[src]
impl Clone for NullWideString
[src]
fn clone(&self) -> NullWideString
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for NullWideString
[src]
impl Default for NullWideString
[src]
fn default() -> NullWideString
[src]
impl Deref for NullWideString
[src]
impl Into<NullWideString> for Vec<NonZeroU16>
[src]
fn into(self) -> NullWideString
[src]
impl Into<Vec<u16>> for NullWideString
[src]
impl PartialEq<NullWideString> for NullWideString
[src]
fn eq(&self, other: &NullWideString) -> bool
[src]
fn ne(&self, other: &NullWideString) -> bool
[src]
impl StructuralPartialEq for NullWideString
[src]
impl ToString for NullWideString
[src]
Auto Trait Implementations
impl RefUnwindSafe for NullWideString
impl Send for NullWideString
impl Sync for NullWideString
impl Unpin for NullWideString
impl UnwindSafe for NullWideString
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,