pub struct WasmConversions;Expand description
Byte-array conversion helpers for WASM bindings.
Implementations§
Source§impl WasmConversions
impl WasmConversions
Sourcepub fn vec_to_uint8array(data: &[u8]) -> Uint8Array
pub fn vec_to_uint8array(data: &[u8]) -> Uint8Array
Copy data into a new JavaScript Uint8Array.
The input slice is not modified; callers that need the source buffer cleared must do so
separately (for example by holding secrets in zeroize::Zeroizing and letting it drop
after this call).
Sourcepub fn uint8array_to_vec(array: &Uint8Array) -> Result<Vec<u8>, Error>
pub fn uint8array_to_vec(array: &Uint8Array) -> Result<Vec<u8>, Error>
Convert WASM Uint8Array to Rust Vec
Validates input size to limit abuse; copies array contents into a new Vec.
Sourcepub fn string_to_algorithm(algorithm_str: &str) -> Result<Algorithm, Error>
pub fn string_to_algorithm(algorithm_str: &str) -> Result<Algorithm, Error>
Convert algorithm string to Algorithm enum
This function provides secure algorithm parsing with:
- Input validation to prevent injection attacks
- Case-insensitive matching for user convenience
- Clear error messages for unsupported algorithms
Sourcepub fn algorithm_to_string(algorithm: Algorithm) -> String
pub fn algorithm_to_string(algorithm: Algorithm) -> String
Convert Algorithm enum to string
This function provides consistent algorithm naming for JavaScript
Sourcepub fn kem_keypair_to_js(
public_key: &[u8],
secret_key: &[u8],
) -> Result<JsValue, Error>
pub fn kem_keypair_to_js( public_key: &[u8], secret_key: &[u8], ) -> Result<JsValue, Error>
Convert KEM keypair to JavaScript object
This function securely serializes keypair data for JavaScript consumption
Sourcepub fn sig_keypair_to_js(
public_key: &[u8],
secret_key: &[u8],
) -> Result<JsValue, Error>
pub fn sig_keypair_to_js( public_key: &[u8], secret_key: &[u8], ) -> Result<JsValue, Error>
Convert signature keypair to JavaScript object
This function securely serializes keypair data for JavaScript consumption
Sourcepub fn hash_result_to_js(
hash: &[u8],
algorithm: Algorithm,
) -> Result<JsValue, Error>
pub fn hash_result_to_js( hash: &[u8], algorithm: Algorithm, ) -> Result<JsValue, Error>
Convert hash result to JavaScript object
This function securely serializes hash data for JavaScript consumption
Sourcepub fn error_to_js(error: &Error) -> JsValue
pub fn error_to_js(error: &Error) -> JsValue
Convert error to JavaScript error
This function provides secure error conversion that doesn’t leak sensitive information
Auto Trait Implementations§
impl Freeze for WasmConversions
impl RefUnwindSafe for WasmConversions
impl Send for WasmConversions
impl Sync for WasmConversions
impl Unpin for WasmConversions
impl UnsafeUnpin for WasmConversions
impl UnwindSafe for WasmConversions
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
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