pub struct SubtleCrypto(/* private fields */);
Implementations§
Source§impl SubtleCrypto
impl SubtleCrypto
pub fn new(browser: &Browser) -> SubtleCrypto
pub fn export_key( &self, format: &dyn ToJs<JsString>, key: &CryptoKey, ) -> Promise<JsValue>
pub fn digest( &self, algorithm: &dyn ToJs<JsValue>, data: &dyn ToJs<JsValue>, ) -> Promise<ArrayBuffer>
pub fn sign( &self, algorithm: &dyn ToJs<JsValue>, key: &CryptoKey, data: &dyn ToJs<JsValue>, ) -> Promise<ArrayBuffer>
pub fn generate_key( &self, algorithm: &dyn ToJs<JsValue>, extractable: &dyn ToJs<JsBoolean>, keyUsages: &dyn ToJs<Array<JsString>>, ) -> Promise<JsValue>
pub fn encrypt( &self, algorithm: &dyn ToJs<JsValue>, key: &CryptoKey, data: &dyn ToJs<JsValue>, ) -> Promise<ArrayBuffer>
pub fn derive_bits( &self, algorithm: &dyn ToJs<JsValue>, baseKey: &CryptoKey, length: &dyn ToJs<JsNumber>, ) -> Promise<ArrayBuffer>
pub fn decrypt( &self, algorithm: &dyn ToJs<JsValue>, key: &CryptoKey, data: &dyn ToJs<JsValue>, ) -> Promise<ArrayBuffer>
pub fn wrap_key( &self, format: &dyn ToJs<JsString>, key: &CryptoKey, wrappingKey: &CryptoKey, wrapAlgorithm: &dyn ToJs<JsValue>, ) -> Promise<ArrayBuffer>
pub fn verify( &self, algorithm: &dyn ToJs<JsValue>, key: &CryptoKey, signature: &dyn ToJs<JsValue>, data: &dyn ToJs<JsValue>, ) -> Promise<JsBoolean>
pub fn import_key( &self, format: &dyn ToJs<JsString>, keyData: &dyn ToJs<JsValue>, algorithm: &dyn ToJs<JsValue>, extractable: &dyn ToJs<JsBoolean>, keyUsages: &dyn ToJs<Array<JsString>>, ) -> Promise<CryptoKey>
pub fn derive_key( &self, algorithm: &dyn ToJs<JsValue>, baseKey: &CryptoKey, derivedKeyType: &dyn ToJs<JsValue>, extractable: &dyn ToJs<JsBoolean>, keyUsages: &dyn ToJs<Array<JsString>>, ) -> Promise<CryptoKey>
pub fn unwrap_key( &self, format: &dyn ToJs<JsString>, wrappedKey: &dyn ToJs<JsValue>, unwrappingKey: &CryptoKey, unwrapAlgorithm: &dyn ToJs<JsValue>, unwrappedKeyAlgorithm: &dyn ToJs<JsValue>, extractable: &dyn ToJs<JsBoolean>, keyUsages: &dyn ToJs<Array<JsString>>, ) -> Promise<CryptoKey>
pub fn get_prototype(browser: &Browser) -> SubtleCrypto
pub fn set_prototype(browser: &Browser, value: &SubtleCrypto)
Methods from Deref<Target = JsObject>§
Sourcepub fn js_get_field(&self, property: &dyn UseInJsCode) -> JsValue
pub fn js_get_field(&self, property: &dyn UseInJsCode) -> JsValue
Get a field value of in this object.
WSDOM provides built-in getters so you should use that instead when possible.
Use js_get_field
only when needed
fn example(browser: Browser) {
// you can get `window["location"]["href"]` like this
let href: JsValue = wsdom::dom::location(&browser).js_get_field(&"href");
// but you should use built-in getters instead
let href: JsString = wsdom::dom::location(&browser).get_href();
}
Sourcepub fn js_set_field(&self, property: &dyn UseInJsCode, value: &dyn UseInJsCode)
pub fn js_set_field(&self, property: &dyn UseInJsCode, value: &dyn UseInJsCode)
Set a field value of in this object.
WSDOM provides built-in setters so you should use that instead when possible.
Use js_set_field
only when needed
fn example(browser: Browser) {
// you can set `window["location"]["href"]` like this
wsdom::dom::location(&browser).js_set_field(&"href", &"https://example.com/");
// but you should use built-in setters instead
wsdom::dom::location(&browser).set_href(&"https://example.com");
}
Sourcepub fn js_call_method<'a>(
&'a self,
method_name: &'a str,
args: impl IntoIterator<Item = &'a dyn UseInJsCode>,
last_arg_variadic: bool,
) -> JsValue
pub fn js_call_method<'a>( &'a self, method_name: &'a str, args: impl IntoIterator<Item = &'a dyn UseInJsCode>, last_arg_variadic: bool, ) -> JsValue
Call a method on this object.
Most types in WSDOM already come with safe Rust wrappers for their methods, so you should use those instead.
fn example(browser: &Browser) {
let console = wsdom::dom::console(browser);
// you can call console.log like this
console.js_call_method("log", [&"hello" as &_], false);
// but the better way is to use
wsdom::dom::console(&browser).log(&[&"Hello" as &_]);
}
Be aware that the first argument (method_name
) is NOT escaped.
Set last_arg_variadic
to true
if you want to “spread” the last argument as obj.method(arg1, arg2, ...arg3)
.
Sourcepub fn js_call_self<'a>(
&'a self,
args: impl IntoIterator<Item = &'a dyn UseInJsCode>,
last_arg_variadic: bool,
) -> JsValue
pub fn js_call_self<'a>( &'a self, args: impl IntoIterator<Item = &'a dyn UseInJsCode>, last_arg_variadic: bool, ) -> JsValue
Call this object: obj()
.
Most types in WSDOM already come with safe Rust wrappers for their methods, so you should use those instead.
Methods from Deref<Target = JsValue>§
pub fn browser(&self) -> &Browser
Sourcepub fn retrieve_json(&self) -> RetrieveFuture<'_, Value>
pub fn retrieve_json(&self) -> RetrieveFuture<'_, Value>
Retrive this value from the JS side to the Rust side. Returns Future whose output is a serde_json::Value.
§use wsdom::dom::Browser
§use wsdom::dom::HTMLInputElement;
async fn example(input: &HTMLInputElement) { let _val = input.get_value().retrieve_json().await; }
Trait Implementations§
Source§impl AsRef<JsObject> for SubtleCrypto
impl AsRef<JsObject> for SubtleCrypto
Source§impl AsRef<JsValue> for SubtleCrypto
impl AsRef<JsValue> for SubtleCrypto
Source§impl AsRef<SubtleCrypto> for SubtleCrypto
impl AsRef<SubtleCrypto> for SubtleCrypto
Source§impl Clone for SubtleCrypto
impl Clone for SubtleCrypto
Source§fn clone(&self) -> SubtleCrypto
fn clone(&self) -> SubtleCrypto
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more