Struct napi::JsStringLatin1

source ·
pub struct JsStringLatin1 { /* private fields */ }

Implementations§

Examples found in repository?
src/js_values/string/latin1.rs (line 27)
26
27
28
  pub fn take(self) -> Vec<u8> {
    self.as_slice().to_vec()
  }
Examples found in repository?
src/js_values/string/latin1.rs (line 36)
35
36
37
38
39
  pub fn into_latin1_string(self) -> Result<String> {
    let mut dst_str = unsafe { String::from_utf8_unchecked(vec![0; self.len() * 2 + 1]) };
    encoding_rs::mem::convert_latin1_to_str(self.buf.as_slice(), dst_str.as_mut_str());
    Ok(dst_str)
  }
Examples found in repository?
src/js_values/string/latin1.rs (line 44)
43
44
45
  fn from(value: JsStringLatin1) -> Self {
    value.take()
  }

Trait Implementations§

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.