pub struct ExtensionState {
pub tabs: Arc<Mutex<Vec<Tab>>>,
pub cookies: Arc<Mutex<Vec<Cookie>>>,
pub storage_local: Arc<Mutex<HashMap<String, String>>>,
pub storage_sync: Arc<Mutex<HashMap<String, String>>>,
pub alarms: Arc<Mutex<Vec<Alarm>>>,
pub pending_messages: Arc<Mutex<Vec<PendingMessage>>>,
pub extension_id: String,
}Expand description
Simulated browser state that chrome.* APIs operate on.
Fields§
§tabs: Arc<Mutex<Vec<Tab>>>Simulated tab list.
Simulated cookie jar.
storage_local: Arc<Mutex<HashMap<String, String>>>Simulated chrome.storage.local.
storage_sync: Arc<Mutex<HashMap<String, String>>>Simulated chrome.storage.sync.
alarms: Arc<Mutex<Vec<Alarm>>>Simulated alarms.
pending_messages: Arc<Mutex<Vec<PendingMessage>>>Message queue (from content scripts or external websites).
extension_id: StringExtension’s own ID.
Implementations§
Source§impl ExtensionState
impl ExtensionState
Sourcepub fn default_with_id(id: &str) -> Self
pub fn default_with_id(id: &str) -> Self
Create default state with a specific extension ID.
Create state with custom cookies.
Sourcepub fn with_storage(self, data: HashMap<String, String>) -> Self
pub fn with_storage(self, data: HashMap<String, String>) -> Self
Pre-load storage with values.
Sourcepub fn queue_message(&self, msg: PendingMessage)
pub fn queue_message(&self, msg: PendingMessage)
Queue a message for delivery to the extension. CRITICAL FIX: Handle poisoned mutex gracefully - drop message if mutex is poisoned.
Sourcepub fn take_messages(&self) -> Vec<PendingMessage>
pub fn take_messages(&self) -> Vec<PendingMessage>
Take all pending messages (drains the queue). CRITICAL FIX: Handle poisoned mutex - recover data even if poisoned.
Trait Implementations§
Source§impl Clone for ExtensionState
impl Clone for ExtensionState
Source§fn clone(&self) -> ExtensionState
fn clone(&self) -> ExtensionState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ExtensionState
impl Debug for ExtensionState
Auto Trait Implementations§
impl Freeze for ExtensionState
impl RefUnwindSafe for ExtensionState
impl Send for ExtensionState
impl Sync for ExtensionState
impl Unpin for ExtensionState
impl UnsafeUnpin for ExtensionState
impl UnwindSafe for ExtensionState
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more