pub struct WasmHashContext { /* private fields */ }Expand description
WASM-compatible Hash context wrapper
This wrapper provides JavaScript-compatible bindings for hash operations:
- Integrates with the new modular architecture
- Includes security validation
- Provides consistent error handling
- Supports all hash algorithms
Implementations§
Source§impl WasmHashContext
impl WasmHashContext
Sourcepub fn new() -> WasmHashContext
pub fn new() -> WasmHashContext
Create a new WASM Hash context with default provider
Sourcepub fn from_hash_context(inner: HashContext) -> WasmHashContext
pub fn from_hash_context(inner: HashContext) -> WasmHashContext
Wrap a Rust HashContext that already has a hash-capable provider (for example from
lib-q-hash::LibQHashProvider in the umbrella crate).
Source§impl WasmHashContext
impl WasmHashContext
Sourcepub fn with_provider(provider: &WasmCryptoProvider) -> WasmHashContext
pub fn with_provider(provider: &WasmCryptoProvider) -> WasmHashContext
Create a new WASM Hash context with custom provider
Sourcepub fn hash(
&mut self,
algorithm: &str,
data: &Uint8Array,
) -> Result<JsValue, JsValue>
pub fn hash( &mut self, algorithm: &str, data: &Uint8Array, ) -> Result<JsValue, JsValue>
Hash data using the specified algorithm
Sourcepub fn security_level(&self) -> u32
pub fn security_level(&self) -> u32
Get the security level of the context
Sourcepub fn is_algorithm_supported(&self, algorithm: &str) -> bool
pub fn is_algorithm_supported(&self, algorithm: &str) -> bool
Check if an algorithm is supported
Sourcepub fn supported_algorithms(&self) -> String
pub fn supported_algorithms(&self) -> String
Get supported algorithms
Trait Implementations§
Source§impl Default for WasmHashContext
impl Default for WasmHashContext
Source§fn default() -> WasmHashContext
fn default() -> WasmHashContext
Returns the “default value” for a type. Read more
Source§impl From<WasmHashContext> for JsValue
impl From<WasmHashContext> for JsValue
Source§fn from(value: WasmHashContext) -> JsValue
fn from(value: WasmHashContext) -> JsValue
Converts to this type from the input type.
Source§impl FromWasmAbi for WasmHashContext
impl FromWasmAbi for WasmHashContext
Source§type Abi = WasmPtr<WasmRefCell<WasmHashContext>>
type Abi = WasmPtr<WasmRefCell<WasmHashContext>>
The Wasm ABI type that this converts from when coming back out from the
ABI boundary.
Source§unsafe fn from_abi(js: <WasmHashContext as FromWasmAbi>::Abi) -> WasmHashContext
unsafe fn from_abi(js: <WasmHashContext as FromWasmAbi>::Abi) -> WasmHashContext
Source§impl IntoWasmAbi for WasmHashContext
impl IntoWasmAbi for WasmHashContext
Source§type Abi = WasmPtr<WasmRefCell<WasmHashContext>>
type Abi = WasmPtr<WasmRefCell<WasmHashContext>>
The Wasm ABI type that this converts into when crossing the ABI
boundary.
Source§fn into_abi(self) -> <WasmHashContext as IntoWasmAbi>::Abi
fn into_abi(self) -> <WasmHashContext as IntoWasmAbi>::Abi
Convert
self into Self::Abi so that it can be sent across the wasm
ABI boundary.Source§impl LongRefFromWasmAbi for WasmHashContext
impl LongRefFromWasmAbi for WasmHashContext
Source§type Abi = WasmPtr<WasmRefCell<WasmHashContext>>
type Abi = WasmPtr<WasmRefCell<WasmHashContext>>
Same as
RefFromWasmAbi::AbiSource§type Anchor = RcRef<WasmHashContext>
type Anchor = RcRef<WasmHashContext>
Same as
RefFromWasmAbi::AnchorSource§unsafe fn long_ref_from_abi(
js: <WasmHashContext as LongRefFromWasmAbi>::Abi,
) -> <WasmHashContext as LongRefFromWasmAbi>::Anchor
unsafe fn long_ref_from_abi( js: <WasmHashContext as LongRefFromWasmAbi>::Abi, ) -> <WasmHashContext as LongRefFromWasmAbi>::Anchor
Same as
RefFromWasmAbi::ref_from_abiSource§impl OptionFromWasmAbi for WasmHashContext
impl OptionFromWasmAbi for WasmHashContext
Source§fn is_none(abi: &<WasmHashContext as FromWasmAbi>::Abi) -> bool
fn is_none(abi: &<WasmHashContext as FromWasmAbi>::Abi) -> bool
Tests whether the argument is a “none” instance. If so it will be
deserialized as
None, and otherwise it will be passed to
FromWasmAbi.Source§impl OptionIntoWasmAbi for WasmHashContext
impl OptionIntoWasmAbi for WasmHashContext
Source§fn none() -> <WasmHashContext as IntoWasmAbi>::Abi
fn none() -> <WasmHashContext as IntoWasmAbi>::Abi
Returns an ABI instance indicating “none”, which JS will interpret as
the
None branch of this option. Read moreSource§impl RefFromWasmAbi for WasmHashContext
impl RefFromWasmAbi for WasmHashContext
Source§type Abi = WasmPtr<WasmRefCell<WasmHashContext>>
type Abi = WasmPtr<WasmRefCell<WasmHashContext>>
The Wasm ABI type references to
Self are recovered from.Source§type Anchor = RcRef<WasmHashContext>
type Anchor = RcRef<WasmHashContext>
The type that holds the reference to
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§unsafe fn ref_from_abi(
js: <WasmHashContext as RefFromWasmAbi>::Abi,
) -> <WasmHashContext as RefFromWasmAbi>::Anchor
unsafe fn ref_from_abi( js: <WasmHashContext as RefFromWasmAbi>::Abi, ) -> <WasmHashContext as RefFromWasmAbi>::Anchor
Source§impl RefMutFromWasmAbi for WasmHashContext
impl RefMutFromWasmAbi for WasmHashContext
Source§type Abi = WasmPtr<WasmRefCell<WasmHashContext>>
type Abi = WasmPtr<WasmRefCell<WasmHashContext>>
Same as
RefFromWasmAbi::AbiSource§type Anchor = RcRefMut<WasmHashContext>
type Anchor = RcRefMut<WasmHashContext>
Same as
RefFromWasmAbi::AnchorSource§unsafe fn ref_mut_from_abi(
js: <WasmHashContext as RefMutFromWasmAbi>::Abi,
) -> <WasmHashContext as RefMutFromWasmAbi>::Anchor
unsafe fn ref_mut_from_abi( js: <WasmHashContext as RefMutFromWasmAbi>::Abi, ) -> <WasmHashContext as RefMutFromWasmAbi>::Anchor
Same as
RefFromWasmAbi::ref_from_abiSource§impl TryFromJsValue for WasmHashContext
impl TryFromJsValue for WasmHashContext
Source§fn try_from_js_value(value: JsValue) -> Result<WasmHashContext, JsValue>
fn try_from_js_value(value: JsValue) -> Result<WasmHashContext, JsValue>
Performs the conversion.
Source§fn try_from_js_value_ref(value: &JsValue) -> Option<WasmHashContext>
fn try_from_js_value_ref(value: &JsValue) -> Option<WasmHashContext>
Performs the conversion.
Source§impl VectorFromWasmAbi for WasmHashContext
impl VectorFromWasmAbi for WasmHashContext
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi( js: <WasmHashContext as VectorFromWasmAbi>::Abi, ) -> Box<[WasmHashContext]>
Source§impl VectorIntoWasmAbi for WasmHashContext
impl VectorIntoWasmAbi for WasmHashContext
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi( vector: Box<[WasmHashContext]>, ) -> <WasmHashContext as VectorIntoWasmAbi>::Abi
Auto Trait Implementations§
impl Freeze for WasmHashContext
impl !RefUnwindSafe for WasmHashContext
impl Send for WasmHashContext
impl Sync for WasmHashContext
impl Unpin for WasmHashContext
impl UnsafeUnpin for WasmHashContext
impl !UnwindSafe for WasmHashContext
Blanket Implementations§
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> 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>
Converts
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>
Converts
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
Same as
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.