pub struct Js;Available on crate feature
js only.Expand description
Implementations§
Source§impl Js
Strings
impl Js
Strings
Sourcepub fn read_str(
buffer: &mut [u8],
write_fn: impl FnMut(*mut u8, js_uint32) -> js_int32,
) -> &str ⓘ
pub fn read_str( buffer: &mut [u8], write_fn: impl FnMut(*mut u8, js_uint32) -> js_int32, ) -> &str ⓘ
Reads a JS string into a Rust &str backed by the given buffer,
truncating if the buffer is too small.
§Panic
Panics if the result is not valid UTF-8.
Sourcepub fn read_string(
write_fn: impl FnMut(*mut u8, js_uint32) -> js_int32,
) -> String ⓘ
Available on unsafe·· and crate feature alloc only.
pub fn read_string( write_fn: impl FnMut(*mut u8, js_uint32) -> js_int32, ) -> String ⓘ
unsafe·· and crate feature alloc only.Allocates a String by calling a JS-backed FFI fn that writes a UTF-8 string into WASM memory.
Allocates a new String from JS (auto-sizing).
- Uses a dynamic buffer, starting with 128 bytes of
capacity. - Retries with exact required capacity if truncation is detected.
Sourcepub fn read_string_capped(
cap: js_uint32,
truncate: bool,
write_fn: impl FnMut(*mut u8, js_uint32) -> js_int32,
) -> String ⓘ
Available on unsafe·· and crate feature alloc only.
pub fn read_string_capped( cap: js_uint32, truncate: bool, write_fn: impl FnMut(*mut u8, js_uint32) -> js_int32, ) -> String ⓘ
unsafe·· and crate feature alloc only.Allocates a String by calling a JS-backed FFI fn that writes a UTF-8 string into WASM memory.
- Uses a dynamic buffer, starting with the given
capacity. - Retries with exact required capacity if truncation is detected (unless
truncate = true). - Assumes the FFI fn returns
js_int32: positive = bytes written, negative = required size.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Js
impl RefUnwindSafe for Js
impl Send for Js
impl Sync for Js
impl Unpin for Js
impl UnsafeUnpin for Js
impl UnwindSafe for Js
Blanket Implementations§
Source§impl<T> AnyExt for T
impl<T> AnyExt for T
Source§fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
Returns a deterministic hash of the
TypeId of Self using a custom hasher.Source§fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Source§fn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
fn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
Available on crate feature
alloc only.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
Mutably borrows from an owned value. Read more
Source§impl<T> ByteSized for T
impl<T> ByteSized for T
Source§const BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
The alignment of this type in bytes.
Source§fn byte_align(&self) -> usize
fn byte_align(&self) -> usize
Returns the alignment of this type in bytes.
Source§fn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Source§impl<T> MemExt for Twhere
T: ?Sized,
impl<T> MemExt for Twhere
T: ?Sized,
Source§const NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Know whether dropping values of this type matters, in compile-time.
Source§fn mem_align_of<T>() -> usize
fn mem_align_of<T>() -> usize
Returns the minimum alignment of the type in bytes. Read more
Source§fn mem_align_of_val(&self) -> usize
fn mem_align_of_val(&self) -> usize
Returns the alignment of the pointed-to value in bytes. Read more
Source§fn mem_size_of<T>() -> usize
fn mem_size_of<T>() -> usize
Returns the size of a type in bytes. Read more
Source§fn mem_size_of_val(&self) -> usize
fn mem_size_of_val(&self) -> usize
Returns the size of the pointed-to value in bytes. Read more
Source§fn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
Returns
true if dropping values of this type matters. Read moreSource§fn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
Forgets about
self without running its destructor. Read moreSource§fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Source§unsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
Available on crate feature
unsafe_layout only.Returns the value of type
T represented by the all-zero byte-pattern. Read moreSource§unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
Available on crate feature
unsafe_layout only.Returns the value of type
T represented by the all-zero byte-pattern. Read moreSource§fn mem_as_bytes(&self) -> &[u8] ⓘ
fn mem_as_bytes(&self) -> &[u8] ⓘ
Available on crate feature
unsafe_slice only.