Skip to main content

script_webcrypto/
traits.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5use script_bindings::DomTypes;
6use script_bindings::reflector::DomObject;
7use script_bindings::tasks::TaskOnce;
8
9use crate::crypto::Crypto;
10use crate::cryptokey::CryptoKey;
11use crate::subtlecrypto::SubtleCrypto;
12
13// This trait enforces the equivalence of all local types with the types in DomTypes.
14trait_set::trait_set! {
15    pub trait Equivalence = DomTypes<
16        Crypto = Crypto<Self>,
17        CryptoKey = CryptoKey<Self>,
18        SubtleCrypto = SubtleCrypto<Self>,
19        // General Bounds
20        GlobalScope: WebCryptoGlobalTrait<Self>>;
21}
22
23pub trait WebCryptoGlobalTrait<D: DomTypes>: Sized + DomObject {
24    fn queue_crypto_task_source(&self, task: impl TaskOnce + 'static);
25    fn queue_dom_manipulation_task_source(&self, task: impl TaskOnce + 'static);
26}