remote_settings::storage

Struct Storage

source
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

source

pub fn new(path: Utf8PathBuf) -> Result<Self>

source

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

source

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.

source

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.

source

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

source

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.

source

pub fn set_attachment( &mut self, collection_url: &str, location: &str, attachment: &[u8], ) -> Result<()>

Set the attachment data stored in the database, clearing out any previously stored data

source

pub fn empty(&mut self) -> Result<()>

Empty out all cached values and start from scratch. This is called when RemoteSettingsService::update_config() is called, since that could change the remote settings server which would invalidate all cached data.

Auto Trait Implementations§

§

impl !Freeze for Storage

§

impl !RefUnwindSafe for Storage

§

impl Send for Storage

§

impl !Sync for Storage

§

impl Unpin for Storage

§

impl !UnwindSafe for Storage

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T