v8

Struct Symbol

Source
#[repr(C)]
pub struct Symbol(/* private fields */);
Expand description

A JavaScript symbol (ECMA-262 edition 6)

Implementations§

Source§

impl Symbol

Source

pub fn new<'s>( scope: &mut HandleScope<'s, ()>, description: Option<Local<'_, String>>, ) -> Local<'s, Symbol>

Create a symbol. If description is not empty, it will be used as the description.

Source

pub fn for_key<'s>( scope: &mut HandleScope<'s, ()>, description: Local<'_, String>, ) -> Local<'s, Symbol>

Access global symbol registry. Note that symbols created this way are never collected, so they should only be used for statically fixed properties. Also, there is only one global description space for the descriptions used as keys. To minimize the potential for clashes, use qualified descriptions as keys. Corresponds to v8::Symbol::For() in C++.

Source

pub fn for_api<'s>( scope: &mut HandleScope<'s, ()>, description: Local<'_, String>, ) -> Local<'s, Symbol>

Retrieve a global symbol. Similar to for_key, but using a separate registry that is not accessible by (and cannot clash with) JavaScript code. Corresponds to v8::Symbol::ForApi() in C++.

Source

pub fn for_global<'s>( scope: &mut HandleScope<'s, ()>, description: Local<'_, String>, ) -> Local<'s, Symbol>

👎Deprecated since 0.77.0: This was documented as for_key but implemented as for_api
Source

pub fn description<'s>( &self, scope: &mut HandleScope<'s, ()>, ) -> Local<'s, Value>

Returns the description string of the symbol, or undefined if none.

Source

pub fn get_async_iterator<'s>( scope: &mut HandleScope<'s, ()>, ) -> Local<'s, Symbol>

Source

pub fn get_has_instance<'s>( scope: &mut HandleScope<'s, ()>, ) -> Local<'s, Symbol>

Source

pub fn get_is_concat_spreadable<'s>( scope: &mut HandleScope<'s, ()>, ) -> Local<'s, Symbol>

Source

pub fn get_iterator<'s>(scope: &mut HandleScope<'s, ()>) -> Local<'s, Symbol>

Source

pub fn get_match<'s>(scope: &mut HandleScope<'s, ()>) -> Local<'s, Symbol>

Source

pub fn get_replace<'s>(scope: &mut HandleScope<'s, ()>) -> Local<'s, Symbol>

Source

pub fn get_split<'s>(scope: &mut HandleScope<'s, ()>) -> Local<'s, Symbol>

Source

pub fn get_to_primitive<'s>( scope: &mut HandleScope<'s, ()>, ) -> Local<'s, Symbol>

Source

pub fn get_to_string_tag<'s>( scope: &mut HandleScope<'s, ()>, ) -> Local<'s, Symbol>

Source

pub fn get_unscopables<'s>(scope: &mut HandleScope<'s, ()>) -> Local<'s, Symbol>

Methods from Deref<Target = Name>§

Source

pub fn get_identity_hash(&self) -> NonZeroI32

Returns the V8 hash value for this value. The current implementation uses a hidden property to store the identity hash.

The return value will never be 0. Also, it is not guaranteed to be unique.

Methods from Deref<Target = Value>§

Source

pub fn is_undefined(&self) -> bool

Returns true if this value is the undefined value. See ECMA-262 4.3.10.

Source

pub fn is_null(&self) -> bool

Returns true if this value is the null value. See ECMA-262 4.3.11.

Source

pub fn is_null_or_undefined(&self) -> bool

Returns true if this value is either the null or the undefined value. See ECMA-262 4.3.11. and 4.3.12

Source

pub fn is_true(&self) -> bool

Returns true if this value is true. This is not the same as BooleanValue(). The latter performs a conversion to boolean, i.e. the result of Boolean(value) in JS, whereas this checks value === true.

Source

pub fn is_false(&self) -> bool

Returns true if this value is false. This is not the same as !BooleanValue(). The latter performs a conversion to boolean, i.e. the result of !Boolean(value) in JS, whereas this checks value === false.

Source

pub fn is_name(&self) -> bool

Returns true if this value is a symbol or a string. This is equivalent to typeof value === 'string' || typeof value === 'symbol' in JS.

Source

pub fn is_string(&self) -> bool

Returns true if this value is an instance of the String type. See ECMA-262 8.4.

Source

pub fn is_symbol(&self) -> bool

Returns true if this value is a symbol. This is equivalent to typeof value === 'symbol' in JS.

Source

pub fn is_function(&self) -> bool

Returns true if this value is a function.

Source

pub fn is_array(&self) -> bool

Returns true if this value is an array. Note that it will return false for an Proxy for an array.

Source

pub fn is_object(&self) -> bool

Returns true if this value is an object.

Source

pub fn is_big_int(&self) -> bool

Returns true if this value is a bigint. This is equivalent to typeof value === 'bigint' in JS.

Source

pub fn is_boolean(&self) -> bool

Returns true if this value is boolean. This is equivalent to typeof value === 'boolean' in JS.

Source

pub fn is_number(&self) -> bool

Returns true if this value is a number.

Source

pub fn is_external(&self) -> bool

Returns true if this value is an External object.

Source

pub fn is_int32(&self) -> bool

Returns true if this value is a 32-bit signed integer.

Source

pub fn is_uint32(&self) -> bool

Returns true if this value is a 32-bit unsigned integer.

Source

pub fn is_date(&self) -> bool

Returns true if this value is a Date.

Source

pub fn is_arguments_object(&self) -> bool

Returns true if this value is an Arguments object.

Source

pub fn is_big_int_object(&self) -> bool

Returns true if this value is a BigInt object.

Source

pub fn is_boolean_object(&self) -> bool

Returns true if this value is a Boolean object.

Source

pub fn is_number_object(&self) -> bool

Returns true if this value is a Number object.

Source

pub fn is_string_object(&self) -> bool

Returns true if this value is a String object.

Source

pub fn is_symbol_object(&self) -> bool

Returns true if this value is a Symbol object.

Source

pub fn is_native_error(&self) -> bool

Returns true if this value is a NativeError.

Source

pub fn is_reg_exp(&self) -> bool

Returns true if this value is a RegExp.

Source

pub fn is_async_function(&self) -> bool

Returns true if this value is an async function.

Source

pub fn is_generator_function(&self) -> bool

Returns true if this value is a Generator function.

Source

pub fn is_promise(&self) -> bool

Returns true if this value is a Promise.

Source

pub fn is_map(&self) -> bool

Returns true if this value is a Map.

Source

pub fn is_set(&self) -> bool

Returns true if this value is a Set.

Source

pub fn is_map_iterator(&self) -> bool

Returns true if this value is a Map Iterator.

Source

pub fn is_set_iterator(&self) -> bool

Returns true if this value is a Set Iterator.

Source

pub fn is_generator_object(&self) -> bool

Returns true if this value is a Generator Object.

Source

pub fn is_weak_map(&self) -> bool

Returns true if this value is a WeakMap.

Source

pub fn is_weak_set(&self) -> bool

Returns true if this value is a WeakSet.

Source

pub fn is_array_buffer(&self) -> bool

Returns true if this value is an ArrayBuffer.

Source

pub fn is_array_buffer_view(&self) -> bool

Returns true if this value is an ArrayBufferView.

Source

pub fn is_typed_array(&self) -> bool

Returns true if this value is one of TypedArrays.

Source

pub fn is_uint8_array(&self) -> bool

Returns true if this value is an Uint8Array.

Source

pub fn is_uint8_clamped_array(&self) -> bool

Returns true if this value is an Uint8ClampedArray.

Source

pub fn is_int8_array(&self) -> bool

Returns true if this value is an Int8Array.

Source

pub fn is_uint16_array(&self) -> bool

Returns true if this value is an Uint16Array.

Source

pub fn is_int16_array(&self) -> bool

Returns true if this value is an Int16Array.

Source

pub fn is_uint32_array(&self) -> bool

Returns true if this value is an Uint32Array.

Source

pub fn is_int32_array(&self) -> bool

Returns true if this value is an Int32Array.

Source

pub fn is_float32_array(&self) -> bool

Returns true if this value is a Float32Array.

Source

pub fn is_float64_array(&self) -> bool

Returns true if this value is a Float64Array.

Source

pub fn is_big_int64_array(&self) -> bool

Returns true if this value is a BigInt64Array.

Source

pub fn is_big_uint64_array(&self) -> bool

Returns true if this value is a BigUint64Array.

Source

pub fn is_data_view(&self) -> bool

Returns true if this value is a DataView.

Source

pub fn is_shared_array_buffer(&self) -> bool

Returns true if this value is a SharedArrayBuffer. This is an experimental feature.

Source

pub fn is_proxy(&self) -> bool

Returns true if this value is a JavaScript Proxy.

Source

pub fn is_wasm_memory_object(&self) -> bool

Returns true if this value is a WasmMemoryObject.

Source

pub fn is_wasm_module_object(&self) -> bool

Returns true if this value is a WasmModuleObject.

Source

pub fn is_module_namespace_object(&self) -> bool

Returns true if the value is a Module Namespace Object.

Source

pub fn strict_equals(&self, that: Local<'_, Value>) -> bool

Source

pub fn same_value(&self, that: Local<'_, Value>) -> bool

Source

pub fn same_value_zero(&self, that: Local<'_, Value>) -> bool

Implements the the abstract operation SameValueZero, which is defined in ECMA-262 6th edition § 7.2.10 (http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero).

This operation is used to compare values for the purpose of insertion into a Set, or determining whether Map keys are equivalent. Its semantics are almost the same as strict_equals() and same_value(), with the following important distinctions:

  • It considers NaN equal to NaN (unlike strict_equals()).
  • It considers -0 equal to 0 (unlike same_value()).
Source

pub fn to_big_int<'s>( &self, scope: &mut HandleScope<'s>, ) -> Option<Local<'s, BigInt>>

Source

pub fn to_number<'s>( &self, scope: &mut HandleScope<'s>, ) -> Option<Local<'s, Number>>

Source

pub fn to_string<'s>( &self, scope: &mut HandleScope<'s>, ) -> Option<Local<'s, String>>

Source

pub fn to_rust_string_lossy(&self, scope: &mut HandleScope<'_>) -> String

Convenience function not present in the original V8 API.

Source

pub fn to_detail_string<'s>( &self, scope: &mut HandleScope<'s>, ) -> Option<Local<'s, String>>

Source

pub fn to_object<'s>( &self, scope: &mut HandleScope<'s>, ) -> Option<Local<'s, Object>>

Source

pub fn to_integer<'s>( &self, scope: &mut HandleScope<'s>, ) -> Option<Local<'s, Integer>>

Source

pub fn to_uint32<'s>( &self, scope: &mut HandleScope<'s>, ) -> Option<Local<'s, Uint32>>

Source

pub fn to_int32<'s>( &self, scope: &mut HandleScope<'s>, ) -> Option<Local<'s, Int32>>

Source

pub fn to_boolean<'s>( &self, scope: &mut HandleScope<'s, ()>, ) -> Local<'s, Boolean>

Perform the equivalent of Boolean(value) in JS. This can never fail.

Source

pub fn instance_of( &self, scope: &mut HandleScope<'_>, object: Local<'_, Object>, ) -> Option<bool>

Source

pub fn number_value(&self, scope: &mut HandleScope<'_>) -> Option<f64>

Source

pub fn integer_value(&self, scope: &mut HandleScope<'_>) -> Option<i64>

Source

pub fn uint32_value(&self, scope: &mut HandleScope<'_>) -> Option<u32>

Source

pub fn int32_value(&self, scope: &mut HandleScope<'_>) -> Option<i32>

Source

pub fn boolean_value(&self, scope: &mut HandleScope<'_, ()>) -> bool

Source

pub fn get_hash(&self) -> NonZeroI32

Returns the V8 hash value for this value. The current implementation uses a hidden property to store the identity hash on some object types.

The return value will never be 0. Also, it is not guaranteed to be unique.

Source

pub fn type_of<'s>(&self, scope: &mut HandleScope<'s, ()>) -> Local<'s, String>

Source

pub fn type_repr(&self) -> &'static str

Utility method that returns human readable representation of the underlying value.

Methods from Deref<Target = Data>§

Source

pub fn is_big_int(&self) -> bool

Returns true if this data is a BigInt.

Source

pub fn is_boolean(&self) -> bool

Returns true if this data is a Boolean.

Source

pub fn is_context(&self) -> bool

Returns true if this data is a Context.

Source

pub fn is_fixed_array(&self) -> bool

Returns true if this data is a FixedArray.

Source

pub fn is_function_template(&self) -> bool

Returns true if this data is a FunctionTemplate.

Source

pub fn is_module(&self) -> bool

Returns true if this data is a Module.

Source

pub fn is_module_request(&self) -> bool

Returns true if this data is a ModuleRequest.

Source

pub fn is_name(&self) -> bool

Returns true if this data is a Name.

Source

pub fn is_number(&self) -> bool

Returns true if this data is a Number.

Source

pub fn is_object_template(&self) -> bool

Returns true if this data is a ObjectTemplate.

Source

pub fn is_primitive(&self) -> bool

Returns true if this data is a Primitive.

Source

pub fn is_private(&self) -> bool

Returns true if this data is a Private.

Source

pub fn is_string(&self) -> bool

Returns true if this data is a String.

Source

pub fn is_symbol(&self) -> bool

Returns true if this data is a Symbol.

Source

pub fn is_value(&self) -> bool

Returns true if this data is a Value.

Trait Implementations§

Source§

impl Debug for Symbol

Source§

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

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

impl Deref for Symbol

Source§

type Target = Name

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl Hash for Symbol

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'s> PartialEq<Data> for Symbol

Source§

fn eq(&self, other: &Data) -> 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.
Source§

impl<'s> PartialEq<Name> for Symbol

Source§

fn eq(&self, other: &Name) -> 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.
Source§

impl<'s> PartialEq<Primitive> for Symbol

Source§

fn eq(&self, other: &Primitive) -> 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.
Source§

impl<'s> PartialEq<Symbol> for Data

Source§

fn eq(&self, other: &Symbol) -> 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.
Source§

impl<'s> PartialEq<Symbol> for Name

Source§

fn eq(&self, other: &Symbol) -> 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.
Source§

impl<'s> PartialEq<Symbol> for Primitive

Source§

fn eq(&self, other: &Symbol) -> 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.
Source§

impl<'s> PartialEq<Symbol> for Value

Source§

fn eq(&self, other: &Symbol) -> 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.
Source§

impl<'s> PartialEq<Value> for Symbol

Source§

fn eq(&self, other: &Value) -> 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.
Source§

impl<'s> PartialEq for Symbol

Source§

fn eq(&self, other: &Symbol) -> 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.
Source§

impl Eq for Symbol

Auto Trait Implementations§

§

impl Freeze for Symbol

§

impl RefUnwindSafe for Symbol

§

impl Send for Symbol

§

impl Sync for Symbol

§

impl Unpin for Symbol

§

impl UnwindSafe for Symbol

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> 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<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.