pub struct UserConsentReceipt {
pub schema: u32,
pub id: String,
pub browser: BrowserKind,
pub profile: String,
pub domains: Option<Vec<String>>,
pub granted_at_ms: u64,
pub expires_at_ms: Option<u64>,
pub revoked_at_ms: Option<u64>,
}Expand description
What the user agreed to: which browser, which profile, which domains. The app persists it
(it is Serialize/Deserialize), shows it, and revokes it. A revoked or expired receipt
refuses every later import, attach and action.
Fields§
§schema: u32§id: StringCaller-chosen unique id (for example a UUID).
browser: BrowserKind§profile: StringSource profile directory name, for example Default or Profile 1.
domains: Option<Vec<String>>Domains (each covers its subdomains) the agent may act on; None means every domain.
granted_at_ms: u64§expires_at_ms: Option<u64>§revoked_at_ms: Option<u64>Implementations§
Source§impl UserConsentReceipt
impl UserConsentReceipt
pub fn new( id: impl Into<String>, browser: BrowserKind, profile: impl Into<String>, domains: Option<Vec<String>>, granted_at_ms: u64, ) -> Result<Self>
Sourcepub fn with_expiry(self, expires_at_ms: u64) -> Self
pub fn with_expiry(self, expires_at_ms: u64) -> Self
Receipt that lapses at expires_at_ms (Unix milliseconds).
Sourcepub fn revoke(&mut self, now_ms: u64)
pub fn revoke(&mut self, now_ms: u64)
Mark the receipt revoked at now_ms. The app persists the result.
pub fn is_active_at(&self, now_ms: u64) -> bool
pub fn check_active(&self) -> Result<()>
Sourcepub fn permits_host(&self, host: &str) -> bool
pub fn permits_host(&self, host: &str) -> bool
Whether host is inside the consented domains (a domain covers its subdomains).
Sourcepub fn permits_url(&self, url: &str) -> bool
pub fn permits_url(&self, url: &str) -> bool
Whether an http(s) url is inside the consented domains.
pub fn to_json(&self) -> Result<String>
pub fn from_json(json: &str) -> Result<Self>
Trait Implementations§
Source§impl Clone for UserConsentReceipt
impl Clone for UserConsentReceipt
Source§impl Debug for UserConsentReceipt
impl Debug for UserConsentReceipt
Source§impl<'de> Deserialize<'de> for UserConsentReceipt
impl<'de> Deserialize<'de> for UserConsentReceipt
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for UserConsentReceipt
Source§impl PartialEq for UserConsentReceipt
impl PartialEq for UserConsentReceipt
Source§impl Serialize for UserConsentReceipt
impl Serialize for UserConsentReceipt
impl StructuralPartialEq for UserConsentReceipt
Auto Trait Implementations§
impl Forget for UserConsentReceipt
impl Freeze for UserConsentReceipt
impl Move for UserConsentReceipt
impl RefUnwindSafe for UserConsentReceipt
impl Send for UserConsentReceiptwhere
RawVecInner: Send,
impl Sync for UserConsentReceiptwhere
RawVecInner: Sync,
impl Unpin for UserConsentReceipt
impl UnsafeUnpin for UserConsentReceiptwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
impl UnwindSafe for UserConsentReceiptwhere
RawVecInner: UnwindSafe,
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