tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

origin_flags.rs (985B)


      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 
      5 //! Helper to iterate over `OriginFlags` bits.
      6 
      7 use crate::gecko_bindings::structs::OriginFlags;
      8 use crate::stylesheets::OriginSet;
      9 
     10 /// Checks that the values for OriginFlags are the ones we expect.
     11 pub fn assert_flags_match() {
     12    use crate::stylesheets::origin::*;
     13    debug_assert_eq!(
     14        OriginFlags::UserAgent.0,
     15        OriginSet::ORIGIN_USER_AGENT.bits()
     16    );
     17    debug_assert_eq!(OriginFlags::Author.0, OriginSet::ORIGIN_AUTHOR.bits());
     18    debug_assert_eq!(OriginFlags::User.0, OriginSet::ORIGIN_USER.bits());
     19 }
     20 
     21 impl From<OriginFlags> for OriginSet {
     22    fn from(flags: OriginFlags) -> Self {
     23        Self::from_bits_retain(flags.0)
     24    }
     25 }
     26 
     27 impl From<OriginSet> for OriginFlags {
     28    fn from(set: OriginSet) -> Self {
     29        OriginFlags(set.bits())
     30    }
     31 }