Copy as Markdown

Other Tools

//
// DO NOT EDIT. THIS FILE IS GENERATED FROM $SRCDIR/toolkit/components/cookiebanners/nsICookieBannerRule.idl
//
/// `interface nsICookieBannerRule : nsISupports`
///
/// ```text
/// /**
/// * A rule containing instructions on how to handle a cookie banner for a specific
/// * domain.
/// */
/// ```
///
// The actual type definition for the interface. This struct has methods
// declared on it which will call through its vtable. You never want to pass
// this type around by value, always pass it behind a reference.
#[repr(C)]
pub struct nsICookieBannerRule {
vtable: &'static nsICookieBannerRuleVTable,
/// This field is a phantomdata to ensure that the VTable type and any
/// struct containing it is not safe to send across threads by default, as
/// XPCOM is generally not threadsafe.
///
/// If this type is marked as [rust_sync], there will be explicit `Send` and
/// `Sync` implementations on this type, which will override the inherited
/// negative impls from `Rc`.
__nosync: ::std::marker::PhantomData<::std::rc::Rc<u8>>,
// Make the rust compiler aware that there might be interior mutability
// in what actually implements the interface. This works around UB
// that a rust lint would make blatantly obvious, but doesn't exist.
// This prevents optimizations, but those optimizations weren't available
// before rustc switched to LLVM 16, and they now cause problems because
// of the UB.
// Until there's a lint available to find all our UB, it's simpler to
// avoid the UB in the first place, at the cost of preventing optimizations
// in places that don't cause UB. But again, those optimizations weren't
// available before.
__maybe_interior_mutability: ::std::cell::UnsafeCell<[u8; 0]>,
}
// Implementing XpCom for an interface exposes its IID, which allows for easy
// use of the `.query_interface<T>` helper method. This also defines that
// method for nsICookieBannerRule.
unsafe impl XpCom for nsICookieBannerRule {
const IID: nsIID = nsID(0xeb1904db, 0xe0d1, 0x4760,
[0xa7, 0x21, 0xdb, 0x76, 0xb1, 0xca, 0x3e, 0x94]);
}
// We need to implement the RefCounted trait so we can be used with `RefPtr`.
// This trait teaches `RefPtr` how to manage our memory.
unsafe impl RefCounted for nsICookieBannerRule {
#[inline]
unsafe fn addref(&self) {
self.AddRef();
}
#[inline]
unsafe fn release(&self) {
self.Release();
}
}
// This trait is implemented on all types which can be coerced to from nsICookieBannerRule.
// It is used in the implementation of `fn coerce<T>`. We hide it from the
// documentation, because it clutters it up a lot.
#[doc(hidden)]
pub trait nsICookieBannerRuleCoerce {
/// Cheaply cast a value of this type from a `nsICookieBannerRule`.
fn coerce_from(v: &nsICookieBannerRule) -> &Self;
}
// The trivial implementation: We can obviously coerce ourselves to ourselves.
impl nsICookieBannerRuleCoerce for nsICookieBannerRule {
#[inline]
fn coerce_from(v: &nsICookieBannerRule) -> &Self {
v
}
}
impl nsICookieBannerRule {
/// Cast this `nsICookieBannerRule` to one of its base interfaces.
#[inline]
pub fn coerce<T: nsICookieBannerRuleCoerce>(&self) -> &T {
T::coerce_from(self)
}
}
// Every interface struct type implements `Deref` to its base interface. This
// causes methods on the base interfaces to be directly avaliable on the
// object. For example, you can call `.AddRef` or `.QueryInterface` directly
// on any interface which inherits from `nsISupports`.
impl ::std::ops::Deref for nsICookieBannerRule {
type Target = nsISupports;
#[inline]
fn deref(&self) -> &nsISupports {
unsafe {
::std::mem::transmute(self)
}
}
}
// Ensure we can use .coerce() to cast to our base types as well. Any type which
// our base interface can coerce from should be coercable from us as well.
impl<T: nsISupportsCoerce> nsICookieBannerRuleCoerce for T {
#[inline]
fn coerce_from(v: &nsICookieBannerRule) -> &Self {
T::coerce_from(v)
}
}
// This struct represents the interface's VTable. A pointer to a statically
// allocated version of this struct is at the beginning of every nsICookieBannerRule
// object. It contains one pointer field for each method in the interface. In
// the case where we can't generate a binding for a method, we include a void
// pointer.
#[doc(hidden)]
#[repr(C)]
pub struct nsICookieBannerRuleVTable {
/// We need to include the members from the base interface's vtable at the start
/// of the VTable definition.
pub __base: nsISupportsVTable,
/* attribute ACString id; */
pub GetId: unsafe extern "system" fn (this: *const nsICookieBannerRule, aId: *mut ::nsstring::nsACString) -> ::nserror::nsresult,
/* attribute ACString id; */
pub SetId: unsafe extern "system" fn (this: *const nsICookieBannerRule, aId: *const ::nsstring::nsACString) -> ::nserror::nsresult,
/* attribute Array<ACString> domains; */
pub GetDomains: unsafe extern "system" fn (this: *const nsICookieBannerRule, aDomains: *mut thin_vec::ThinVec<::nsstring::nsCString>) -> ::nserror::nsresult,
/* attribute Array<ACString> domains; */
pub SetDomains: unsafe extern "system" fn (this: *const nsICookieBannerRule, aDomains: *const thin_vec::ThinVec<::nsstring::nsCString>) -> ::nserror::nsresult,
/* readonly attribute Array<nsICookieRule> cookiesOptOut; */
pub GetCookiesOptOut: unsafe extern "system" fn (this: *const nsICookieBannerRule, aCookiesOptOut: *mut thin_vec::ThinVec<Option<RefPtr<nsICookieRule>>>) -> ::nserror::nsresult,
/* readonly attribute Array<nsICookieRule> cookiesOptIn; */
pub GetCookiesOptIn: unsafe extern "system" fn (this: *const nsICookieBannerRule, aCookiesOptIn: *mut thin_vec::ThinVec<Option<RefPtr<nsICookieRule>>>) -> ::nserror::nsresult,
/* [infallible] readonly attribute boolean isGlobalRule; */
pub GetIsGlobalRule: unsafe extern "system" fn (this: *const nsICookieBannerRule, aIsGlobalRule: *mut bool) -> ::nserror::nsresult,
/* [noscript] Array<nsICookieRule> getCookies (in boolean aIsOptOut, [optional] in ACString aDomain); */
pub GetCookies: unsafe extern "system" fn (this: *const nsICookieBannerRule, aIsOptOut: bool, aDomain: *const ::nsstring::nsACString, _retval: *mut thin_vec::ThinVec<Option<RefPtr<nsICookieRule>>>) -> ::nserror::nsresult,
/* void clearCookies (); */
pub ClearCookies: unsafe extern "system" fn (this: *const nsICookieBannerRule) -> ::nserror::nsresult,
/* void addCookie (in boolean aIsOptOut, in ACString aName, in AUTF8String aValue, in AUTF8String aHost, in AUTF8String aPath, in int64_t aExpiryRelative, in AUTF8String aUnsetValue, in boolean aIsSecure, in boolean aIsHttpOnly, in boolean aIsSession, in int32_t aSameSite, in nsICookie_schemeType aSchemeMap); */
pub AddCookie: unsafe extern "system" fn (this: *const nsICookieBannerRule, aIsOptOut: bool, aName: *const ::nsstring::nsACString, aValue: *const ::nsstring::nsACString, aHost: *const ::nsstring::nsACString, aPath: *const ::nsstring::nsACString, aExpiryRelative: i64, aUnsetValue: *const ::nsstring::nsACString, aIsSecure: bool, aIsHttpOnly: bool, aIsSession: bool, aSameSite: i32, aSchemeMap: u8) -> ::nserror::nsresult,
/* readonly attribute nsIClickRule clickRule; */
pub GetClickRule: unsafe extern "system" fn (this: *const nsICookieBannerRule, aClickRule: *mut *const nsIClickRule) -> ::nserror::nsresult,
/* void addClickRule (in ACString aPresence, [optional] in boolean aSkipPresenceVisibilityCheck, [optional] in nsIClickRule_RunContext aRunContext, [optional] in ACString aHide, [optional] in ACString aOptOut, [optional] in ACString aOptIn); */
pub AddClickRule: unsafe extern "system" fn (this: *const nsICookieBannerRule, aPresence: *const ::nsstring::nsACString, aSkipPresenceVisibilityCheck: bool, aRunContext: u8, aHide: *const ::nsstring::nsACString, aOptOut: *const ::nsstring::nsACString, aOptIn: *const ::nsstring::nsACString) -> ::nserror::nsresult,
/* void clearClickRule (); */
pub ClearClickRule: unsafe extern "system" fn (this: *const nsICookieBannerRule) -> ::nserror::nsresult,
}
// The implementations of the function wrappers which are exposed to rust code.
// Call these methods rather than manually calling through the VTable struct.
impl nsICookieBannerRule {
/// `attribute ACString id;`
#[inline]
pub unsafe fn GetId(&self, aId: *mut ::nsstring::nsACString) -> ::nserror::nsresult {
((*self.vtable).GetId)(self, aId)
}
/// `attribute ACString id;`
#[inline]
pub unsafe fn SetId(&self, aId: *const ::nsstring::nsACString) -> ::nserror::nsresult {
((*self.vtable).SetId)(self, aId)
}
/// `attribute Array<ACString> domains;`
#[inline]
pub unsafe fn GetDomains(&self, aDomains: *mut thin_vec::ThinVec<::nsstring::nsCString>) -> ::nserror::nsresult {
((*self.vtable).GetDomains)(self, aDomains)
}
/// `attribute Array<ACString> domains;`
#[inline]
pub unsafe fn SetDomains(&self, aDomains: *const thin_vec::ThinVec<::nsstring::nsCString>) -> ::nserror::nsresult {
((*self.vtable).SetDomains)(self, aDomains)
}
/// `readonly attribute Array<nsICookieRule> cookiesOptOut;`
#[inline]
pub unsafe fn GetCookiesOptOut(&self, aCookiesOptOut: *mut thin_vec::ThinVec<Option<RefPtr<nsICookieRule>>>) -> ::nserror::nsresult {
((*self.vtable).GetCookiesOptOut)(self, aCookiesOptOut)
}
/// `readonly attribute Array<nsICookieRule> cookiesOptIn;`
#[inline]
pub unsafe fn GetCookiesOptIn(&self, aCookiesOptIn: *mut thin_vec::ThinVec<Option<RefPtr<nsICookieRule>>>) -> ::nserror::nsresult {
((*self.vtable).GetCookiesOptIn)(self, aCookiesOptIn)
}
/// ```text
/// /**
/// * Indicates whether this rule is a global rule according to the domains
/// * field. We say this rule is global if the domains field is an empty array.
/// */
/// ```
///
/// `[infallible] readonly attribute boolean isGlobalRule;`
#[inline]
pub unsafe fn GetIsGlobalRule(&self) -> bool {
let mut result = <bool as ::std::default::Default>::default();
let _rv = ((*self.vtable).GetIsGlobalRule)(self, &mut result);
debug_assert!(_rv.succeeded());
result
}
/// ```text
/// /**
/// * Get the list of cookies associated with this rule.
/// * aIsOptOut - Whether to return opt-out cookies (true) or opt-in cookies
/// * (false).
/// * aDomain - Optional, when passed returns a copy of each rule with cookie
/// * host set to .<domain>. See nsICookieRule::copyForDomain.
/// */
/// ```
///
/// `[noscript] Array<nsICookieRule> getCookies (in boolean aIsOptOut, [optional] in ACString aDomain);`
#[inline]
pub unsafe fn GetCookies(&self, aIsOptOut: bool, aDomain: *const ::nsstring::nsACString, _retval: *mut thin_vec::ThinVec<Option<RefPtr<nsICookieRule>>>) -> ::nserror::nsresult {
((*self.vtable).GetCookies)(self, aIsOptOut, aDomain, _retval)
}
/// ```text
/// /**
/// * Clear both lists of opt-in and opt-out cookies.
/// */
/// ```
///
/// `void clearCookies ();`
#[inline]
pub unsafe fn ClearCookies(&self, ) -> ::nserror::nsresult {
((*self.vtable).ClearCookies)(self, )
}
/// ```text
/// /**
/// * Add an opt-in or opt-out cookie to the rule.
///
/// * aIsOptOut - Whether this is an opt-out cookie (true) or opt-in cookie (false).
/// * aExpiryRelative - See nsICookieRule.
/// * aUnsetValue - See nsICookieRule.
/// * For a description of the other fields see nsICookieManager#addNative.
/// */
/// ```
///
/// `void addCookie (in boolean aIsOptOut, in ACString aName, in AUTF8String aValue, in AUTF8String aHost, in AUTF8String aPath, in int64_t aExpiryRelative, in AUTF8String aUnsetValue, in boolean aIsSecure, in boolean aIsHttpOnly, in boolean aIsSession, in int32_t aSameSite, in nsICookie_schemeType aSchemeMap);`
#[inline]
pub unsafe fn AddCookie(&self, aIsOptOut: bool, aName: *const ::nsstring::nsACString, aValue: *const ::nsstring::nsACString, aHost: *const ::nsstring::nsACString, aPath: *const ::nsstring::nsACString, aExpiryRelative: i64, aUnsetValue: *const ::nsstring::nsACString, aIsSecure: bool, aIsHttpOnly: bool, aIsSession: bool, aSameSite: i32, aSchemeMap: u8) -> ::nserror::nsresult {
((*self.vtable).AddCookie)(self, aIsOptOut, aName, aValue, aHost, aPath, aExpiryRelative, aUnsetValue, aIsSecure, aIsHttpOnly, aIsSession, aSameSite, aSchemeMap)
}
/// `readonly attribute nsIClickRule clickRule;`
#[inline]
pub unsafe fn GetClickRule(&self, aClickRule: *mut *const nsIClickRule) -> ::nserror::nsresult {
((*self.vtable).GetClickRule)(self, aClickRule)
}
/// ```text
/// /**
/// * Add a click rule to the rule.
/// *
/// * aPresence - The CSS selector for detecting the presence of the cookie
/// * banner
/// * aSkipPresenceVisibilityCheck - Whether to skip checking if the banner is
/// * visible before clicking it.
/// * aHide - The CSS selector for hiding the cookie banner
/// * aOptOut - The CSS selector for selecting the opt-out banner button
/// * aOptIn - The CSS selector for selecting the opt-in banner button
/// */
/// ```
///
/// `void addClickRule (in ACString aPresence, [optional] in boolean aSkipPresenceVisibilityCheck, [optional] in nsIClickRule_RunContext aRunContext, [optional] in ACString aHide, [optional] in ACString aOptOut, [optional] in ACString aOptIn);`
#[inline]
pub unsafe fn AddClickRule(&self, aPresence: *const ::nsstring::nsACString, aSkipPresenceVisibilityCheck: bool, aRunContext: u8, aHide: *const ::nsstring::nsACString, aOptOut: *const ::nsstring::nsACString, aOptIn: *const ::nsstring::nsACString) -> ::nserror::nsresult {
((*self.vtable).AddClickRule)(self, aPresence, aSkipPresenceVisibilityCheck, aRunContext, aHide, aOptOut, aOptIn)
}
/// ```text
/// /**
/// * Clear the click rule.
/// */
/// ```
///
/// `void clearClickRule ();`
#[inline]
pub unsafe fn ClearClickRule(&self, ) -> ::nserror::nsresult {
((*self.vtable).ClearClickRule)(self, )
}
}