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 set_records
/ merge_records
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 set_records
.
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 set_records(
&mut self,
collection_url: &str,
records: &[RemoteSettingsRecord],
) -> Result<()>
pub fn set_records( &mut self, collection_url: &str, records: &[RemoteSettingsRecord], ) -> Result<()>
Set the list of records stored in the database, clearing out any previously stored records
sourcepub fn merge_records(
&mut self,
collection_url: &str,
records: &[RemoteSettingsRecord],
) -> Result<()>
pub fn merge_records( &mut self, collection_url: &str, records: &[RemoteSettingsRecord], ) -> Result<()>
Merge new records with records stored in the database
Records with deleted=false
will be inserted into the DB, replacing any previously stored
records with the same ID. Records with deleted=true
will be removed.