Struct ByteString

Source
pub struct ByteString { /* private fields */ }
Expand description

Wrapper for WebIDL ByteString.

Implementations§

Source§

impl ByteString

Source

pub fn byte_len(&self) -> usize

Number of UTF‑8 bytes (same as str::len()).

Source

pub fn is_empty(&self) -> bool

len() == 0 convenience.

Source

pub fn char_at(&self, i: usize) -> Option<char>

Scalar lookup; returns None if index is out of bounds.

Source

pub fn as_str(&self) -> &str

Borrow the JavaScript string as &str (UTF‑8 view).

Source

pub fn length(&self) -> usize

Number of UTF-16 code units (JSString.length).

Source

pub fn char_code_at(&self, idx: usize) -> u16

Returns the 16-bit code unit at idx (like charCodeAt).

Source

pub fn set(&self, idx: usize, val: char)

Source

pub fn at(&self, idx: isize) -> Option<Self>

Source

pub fn code_point_at(&self, idx: usize) -> Option<u32>

Source

pub fn concat(&self, rhs: &Self) -> Self

Source

pub fn ends_with(&self, pat: &str) -> bool

Source

pub fn includes(&self, pat: &str) -> bool

Source

pub fn index_of(&self, pat: &str) -> Option<usize>

String.prototype.indexOf Returns None when not found.

Source

pub fn is_well_formed(&self) -> bool

Source

pub fn last_index_of(&self, pat: &str) -> Option<usize>

Source

pub fn locale_compare(&self, other: &str) -> i32

Source

pub fn match_(&self, pat: &Val) -> Val

Source

pub fn match_all(&self, pat: &Val) -> Val

Source

pub fn normalize(&self, form: Option<&str>) -> Self

Source

pub fn pad_end(&self, target_len: usize, pad: Option<&str>) -> Self

Source

pub fn pad_start(&self, target_len: usize, pad: Option<&str>) -> Self

Source

pub fn repeat(&self, count: usize) -> Self

Source

pub fn replace(&self, pat: &Val, repl: &Val) -> Self

Source

pub fn replace_all(&self, pat: &Val, repl: &Val) -> Self

Source

pub fn search(&self, pat: &Val) -> isize

Source

pub fn slice(&self, start: isize, end: Option<isize>) -> Self

Source

pub fn split(&self, sep: &str) -> Sequence<Self>

Source

pub fn starts_with(&self, pat: &str) -> bool

Source

pub fn substring(&self, start: usize, end: Option<usize>) -> Self

Source

pub fn to_locale_lower_case(&self) -> Self

Source

pub fn to_locale_upper_case(&self) -> Self

Source

pub fn to_lower_case(&self) -> Self

Source

pub fn to_upper_case(&self) -> Self

Source

pub fn to_well_formed(&self) -> Self

Source

pub fn trim(&self) -> Self

Source

pub fn trim_end(&self) -> Self

Source

pub fn trim_start(&self) -> Self

Methods from Deref<Target = Val>§

Source

pub fn get<T>(&self, prop: T) -> Val
where T: Into<Val>,

Gets the property prop

Source

pub fn set<K, V>(&self, prop: K, val: V)
where K: Into<Val>, V: Into<Val>,

Set the underlying js object property prop to val

Source

pub fn has<T>(&self, prop: T) -> bool
where T: Into<Val>,

Checks whether a property prop exists

Source

pub fn has_own_property(&self, prop: &str) -> bool

Checks whether a non-inherited property prop exists

Source

pub fn type_of(&self) -> String

Gets the typeof the underlying js object

Source

pub fn at<T>(&self, idx: T) -> Val
where T: Into<Val>,

Gets the element at index idx. Assumes the underlying js type is indexable

Source

pub fn to_vec<V>(&self) -> Vec<V>
where V: FromVal,

Converts the underlying js array to a Vec of V

Source

pub fn call(&self, f: &str, args: &[Val]) -> Val

Calls the method f with args, can return an undefined js value

Source

pub fn new(&self, args: &[Val]) -> Val

Calls the object’s constructor with args constructing a new object

Source

pub fn invoke(&self, args: &[Val]) -> Val

Invokes the function object with args, can return an undefined js value

Source

pub fn await_(&self) -> Val

Awaits the invoked function object

Source

pub fn instanceof(&self, v: Val) -> bool

Checks whether this Val is an instanceof v

Source

pub fn as_<T>(&self) -> T
where T: FromVal,

Trait Implementations§

Source§

impl Add for ByteString

Source§

type Output = ByteString

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl AsRef<str> for ByteString

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for ByteString

Source§

fn clone(&self) -> ByteString

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ByteString

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for ByteString

Source§

type Target = Val

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for ByteString

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl Display for ByteString

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&str> for ByteString

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl From<ByteString> for Val

Source§

fn from(x: ByteString) -> Val

Converts to this type from the input type.
Source§

impl From<String> for ByteString

Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl FromVal for ByteString

Source§

fn from_val(v: &Val) -> Self

Creates a Val object from another
Source§

fn take_ownership(v: Handle) -> Self

Takes the ownership of a handle
Source§

fn as_handle(&self) -> Handle

Returns the raw js handle
Source§

impl PartialEq<str> for ByteString

Source§

fn eq(&self, other: &str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.