pub struct Storage { /* private fields */ }
Expand description
Internal storage type
This will store downloaded records/attachments in a SQLite database. Nothing is implemented yet other than the initial API.
Most methods input a collection_url
parameter, is a URL that includes the remote settings
server, bucket, and collection. If the collection_url
for a get method does not match the one
for a set method, then this means the application has switched their remote settings config and
Storage should pretend like nothing is stored in the database.
The reason for this is the crate::RemoteSettingsService::update_config method. If a consumer
passes a new server or bucket to update_config
, we don’t want to be using cached data from
the previous config.
Implementations§
source§impl Storage
impl Storage
pub fn new(path: Utf8PathBuf) -> Result<Self>
sourcepub fn get_last_modified_timestamp(
&self,
collection_url: &str,
) -> Result<Option<u64>>
pub fn get_last_modified_timestamp( &self, collection_url: &str, ) -> Result<Option<u64>>
Get the last modified timestamp for the stored records
Returns None if no records are stored or if collection_url
does not match the
last collection_url
passed to insert_collection_content
sourcepub fn get_records(
&mut self,
collection_url: &str,
) -> Result<Option<Vec<RemoteSettingsRecord>>>
pub fn get_records( &mut self, collection_url: &str, ) -> Result<Option<Vec<RemoteSettingsRecord>>>
Get cached records for this collection
Returns None if no records are stored or if collection_url
does not match the collection_url
passed
to insert_collection_content
.
sourcepub fn get_collection_metadata(
&self,
collection_url: &str,
) -> Result<Option<CollectionMetadata>>
pub fn get_collection_metadata( &self, collection_url: &str, ) -> Result<Option<CollectionMetadata>>
Get cached metadata for this collection
Returns None if no data is stored or if collection_url
does not match the collection_url
passed
to insert_collection_content
.
sourcepub fn get_attachment(
&self,
collection_url: &str,
metadata: Attachment,
) -> Result<Option<Vec<u8>>>
pub fn get_attachment( &self, collection_url: &str, metadata: Attachment, ) -> Result<Option<Vec<u8>>>
Get cached attachment data
This returns the last attachment data sent to Self::set_attachment.
Returns None if no attachment data is stored or if collection_url
does not match the collection_url
passed to set_attachment
.
sourcepub fn insert_collection_content(
&mut self,
collection_url: &str,
records: &[RemoteSettingsRecord],
last_modified: u64,
metadata: CollectionMetadata,
) -> Result<()>
pub fn insert_collection_content( &mut self, collection_url: &str, records: &[RemoteSettingsRecord], last_modified: u64, metadata: CollectionMetadata, ) -> Result<()>
Set cached content for this collection.