pub struct ArgReader<'a> { /* private fields */ }Expand description
Typed argument reader wrapping SpiderMonkey CallArgs.
Provides safe extraction of typed arguments from JS function calls.
Implementations§
Source§impl<'a> ArgReader<'a>
impl<'a> ArgReader<'a>
Sourcepub unsafe fn new(cx: *mut JSContext, args: &'a CallArgs) -> ArgReader<'a>
pub unsafe fn new(cx: *mut JSContext, args: &'a CallArgs) -> ArgReader<'a>
Create an ArgReader from a JSContext and CallArgs.
§Safety
cx must be a valid JSContext. args must be valid CallArgs for the current call.
Sourcepub unsafe fn get_raw(&self, index: u32) -> Value
pub unsafe fn get_raw(&self, index: u32) -> Value
Get raw JSVal at index, or UndefinedValue if out of bounds.
§Safety
cx must be a valid JSContext. index must be in bounds or handled gracefully.
Sourcepub unsafe fn get_string(&self, index: u32) -> String
pub unsafe fn get_string(&self, index: u32) -> String
Extract a string argument. Returns default if missing or not a string.
§Safety
Must be called within a valid JSContext scope.
Sourcepub unsafe fn get_optional_string(&self, index: u32) -> Option<String>
pub unsafe fn get_optional_string(&self, index: u32) -> Option<String>
Sourcepub unsafe fn get_int(&self, index: u32) -> i32
pub unsafe fn get_int(&self, index: u32) -> i32
Extract an i32 argument. Returns default if missing or not a number.
§Safety
Must be called within a valid JSContext scope.
Sourcepub unsafe fn get_f64(&self, index: u32) -> f64
pub unsafe fn get_f64(&self, index: u32) -> f64
Extract an f64 argument. Returns default if missing or not a number.
§Safety
Must be called within a valid JSContext scope.
Sourcepub unsafe fn get_bool(&self, index: u32) -> bool
pub unsafe fn get_bool(&self, index: u32) -> bool
Extract a bool argument. Returns false if missing or not a boolean.
§Safety
Must be called within a valid JSContext scope.
Sourcepub unsafe fn get_object(&self, index: u32) -> *mut JSObject
pub unsafe fn get_object(&self, index: u32) -> *mut JSObject
Extract a JSObject pointer argument. Returns null if missing or not an object.
§Safety
Must be called within a valid JSContext scope.
Sourcepub unsafe fn return_undefined(&self)
pub unsafe fn return_undefined(&self)
Sourcepub unsafe fn return_value(&self, val: JsValue)
pub unsafe fn return_value(&self, val: JsValue)
Sourcepub unsafe fn return_bool(&self, v: bool)
pub unsafe fn return_bool(&self, v: bool)
Sourcepub unsafe fn return_int(&self, v: i32)
pub unsafe fn return_int(&self, v: i32)
Sourcepub unsafe fn return_f64(&self, v: f64)
pub unsafe fn return_f64(&self, v: f64)
Sourcepub unsafe fn return_string(&self, s: &str)
pub unsafe fn return_string(&self, s: &str)
Set the return value to a Rust string (creates a JSString).
§Safety
Must be called within a valid JSContext scope.
Auto Trait Implementations§
impl<'a> !Send for ArgReader<'a>
impl<'a> !Sync for ArgReader<'a>
impl<'a> Freeze for ArgReader<'a>
impl<'a> RefUnwindSafe for ArgReader<'a>
impl<'a> Unpin for ArgReader<'a>
impl<'a> UnsafeUnpin for ArgReader<'a>
impl<'a> UnwindSafe for ArgReader<'a>
Blanket Implementations§
Source§impl<T> AsCtxPtr for Twhere
T: ?Sized,
impl<T> AsCtxPtr for Twhere
T: ?Sized,
Source§fn as_ctx_ptr(&self) -> *mut Selfwhere
Self: Sized,
fn as_ctx_ptr(&self) -> *mut Selfwhere
Self: Sized,
self’s address as *mut Self for deferred-task / scopeguard /
ref_guard ctx slots. The closures/trampolines deref it as shared
(&*p) — every method they reach is &self post-R-2, so no write
provenance is required; the *mut spelling is purely to match the
existing DerefOnDrop / HasAutoFlush / RefCount ABI.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Filterable for T
impl<T> Filterable for T
Source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more