Skip to main content

WasmThreadCapabilities

Struct WasmThreadCapabilities 

Source
pub struct WasmThreadCapabilities {
    pub cross_origin_isolated: bool,
    pub shared_array_buffer: bool,
    pub atomics: bool,
    pub hardware_concurrency: u32,
    pub coop_header: Option<String>,
    pub coep_header: Option<String>,
    pub is_secure_context: bool,
    pub errors: Vec<String>,
}
Expand description

WASM threading capabilities detected from browser context

Fields§

§cross_origin_isolated: bool

Whether crossOriginIsolated is true in the browser

§shared_array_buffer: bool

Whether SharedArrayBuffer is available

§atomics: bool

Whether Atomics is available

§hardware_concurrency: u32

navigator.hardwareConcurrency value

§coop_header: Option<String>

COOP header value (if present)

§coep_header: Option<String>

COEP header value (if present)

§is_secure_context: bool

Whether the page is served over HTTPS (required for SAB)

§errors: Vec<String>

Error messages collected during detection

Implementations§

Source§

impl WasmThreadCapabilities

Source

pub fn full_support() -> Self

Create capabilities indicating full threading support

Source

pub fn no_support() -> Self

Create capabilities indicating no threading support

Source

pub fn assert_threading_ready(&self) -> Result<(), CapabilityError>

Assert all requirements for multi-threaded WASM

§Errors

Returns error with detailed message if any requirement is not met

Source

pub fn assert_streaming_ready(&self) -> Result<(), CapabilityError>

Assert requirements for streaming audio processing

Streaming requires threading for real-time performance

§Errors

Returns error if streaming requirements are not met

Source

pub fn optimal_threads(&self) -> u32

Get recommended thread count for optimal performance

Per whisper.apr: N_threads = max(1, min(hardwareConcurrency - 1, 8))

Source

pub fn is_threading_available(&self) -> bool

Check if threading is available (non-asserting)

Source

pub fn shared_array_buffer_status(&self) -> CapabilityStatus

Check SharedArrayBuffer status

Source

pub fn detection_js() -> &'static str

Generate JavaScript code to detect capabilities in browser

Source

pub fn from_json(json: &str) -> Result<Self, CapabilityError>

Parse capabilities from JSON response

§Errors

Returns error if JSON parsing fails

Trait Implementations§

Source§

impl Clone for WasmThreadCapabilities

Source§

fn clone(&self) -> WasmThreadCapabilities

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 WasmThreadCapabilities

Source§

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

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

impl Default for WasmThreadCapabilities

Source§

fn default() -> WasmThreadCapabilities

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

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<T> Same for T

Source§

type Output = T

Should always be Self
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, 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.