Skip to main content

ProxyState

Struct ProxyState 

Source
pub struct ProxyState {
    pub target: Option<Gc<JsObject>>,
    pub handler: Option<Value>,
    pub callable: bool,
    pub constructible: bool,
}
Expand description

The two slots of a proxy, shared with its revoke function.

None in both slots means revoked: every operation then throws a TypeError, and the target and handler are no longer reachable — which is the whole point of Proxy.revocable.

Fields§

§target: Option<Gc<JsObject>>

The object the traps receive, or None once revoked.

§handler: Option<Value>

The trap table, or None once revoked.

§callable: bool

Whether this proxy has a [[Call]], decided once when it is created.

Revoking drops the target but does not take [[Call]] away, so this cannot be re-derived from target being Some: typeof p.proxy has to stay "function" after Proxy.revocable(function(){}, {}).revoke(), and the reference agrees.

§constructible: bool

Whether this proxy has a [[Construct]], decided once when it is created.

Same reasoning as ProxyState::callable, and the two are genuinely independent: Proxy.revocable(function(){}, {}) is both callable and constructible, while a proxy over an arrow function is callable and not constructible.

Trait Implementations§

Source§

impl Default for ProxyState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Trace for ProxyState

Source§

fn trace(&self, tracer: &mut Tracer<'_>)

Report every Gc owned by self to tracer.

Auto Trait Implementations§

§

impl !RefUnwindSafe for ProxyState

§

impl !Send for ProxyState

§

impl !Sync for ProxyState

§

impl !UnwindSafe for ProxyState

§

impl Forget for ProxyState

§

impl Freeze for ProxyState
where *const GcBox<JsObject> is !null: Freeze, *const GcBox<JsString> is !null: Freeze, *const GcBox<JsSymbol> is !null: Freeze, *const GcBox<BigInt> is !null: Freeze,

§

impl Move for ProxyState

§

impl Unpin for ProxyState
where *const GcBox<JsObject> is !null: Unpin, *const GcBox<JsString> is !null: Unpin, *const GcBox<JsSymbol> is !null: Unpin, *const GcBox<BigInt> is !null: Unpin,

§

impl UnsafeUnpin for ProxyState
where *const GcBox<JsObject> is !null: UnsafeUnpin, *const GcBox<JsString> is !null: UnsafeUnpin, *const GcBox<JsSymbol> is !null: UnsafeUnpin, *const GcBox<BigInt> is !null: UnsafeUnpin,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.