diff options
author | Martin Robinson <mrobinson@igalia.com> | 2023-10-05 19:47:39 +0200 |
---|---|---|
committer | Martin Robinson <mrobinson@igalia.com> | 2023-11-03 15:38:18 +0000 |
commit | f4d3af296c05260dfbb3deea4f8fa400cb6887d3 (patch) | |
tree | 169db2cc68e01a755b30500dd525f1a2ec2da861 /components/shared/net/storage_thread.rs | |
parent | 863529d9622c68f0a9535225237eb5e5c5b8c757 (diff) | |
download | servo-f4d3af296c05260dfbb3deea4f8fa400cb6887d3.tar.gz servo-f4d3af296c05260dfbb3deea4f8fa400cb6887d3.zip |
Move `*_traits` and other shared types to `shared`
This is the start of the organization of types that are in their own
crates in order to break dependency cycles between other crates. The
idea here is that putting these packages into their own directory is the
first step toward cleaning them up. They have grown organically and it
is difficult to explain to new folks where to put new shared types. Many
of these crates contain more than traits or don't contain traits at all.
Notably, `script_traits` isn't touched because it is vendored from
Gecko. Eventually this will move to `third_party`.
Diffstat (limited to 'components/shared/net/storage_thread.rs')
-rw-r--r-- | components/shared/net/storage_thread.rs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/components/shared/net/storage_thread.rs b/components/shared/net/storage_thread.rs new file mode 100644 index 00000000000..0253603016e --- /dev/null +++ b/components/shared/net/storage_thread.rs @@ -0,0 +1,48 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + +use ipc_channel::ipc::IpcSender; +use malloc_size_of_derive::MallocSizeOf; +use serde::{Deserialize, Serialize}; +use servo_url::ServoUrl; + +#[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, Serialize)] +pub enum StorageType { + Session, + Local, +} + +/// Request operations on the storage data associated with a particular url +#[derive(Debug, Deserialize, Serialize)] +pub enum StorageThreadMsg { + /// gets the number of key/value pairs present in the associated storage data + Length(IpcSender<usize>, ServoUrl, StorageType), + + /// gets the name of the key at the specified index in the associated storage data + Key(IpcSender<Option<String>>, ServoUrl, StorageType, u32), + + /// Gets the available keys in the associated storage data + Keys(IpcSender<Vec<String>>, ServoUrl, StorageType), + + /// gets the value associated with the given key in the associated storage data + GetItem(IpcSender<Option<String>>, ServoUrl, StorageType, String), + + /// sets the value of the given key in the associated storage data + SetItem( + IpcSender<Result<(bool, Option<String>), ()>>, + ServoUrl, + StorageType, + String, + String, + ), + + /// removes the key/value pair for the given key in the associated storage data + RemoveItem(IpcSender<Option<String>>, ServoUrl, StorageType, String), + + /// clears the associated storage data by removing all the key/value pairs + Clear(IpcSender<bool>, ServoUrl, StorageType), + + /// send a reply when done cleaning up thread resources and then shut it down + Exit(IpcSender<()>), +} |