Skip to main content

SettingsStore

Struct SettingsStore 

Source
pub struct SettingsStore { /* private fields */ }
Expand description

The settings document (<data_dir>/<namespace>/settings.json) and the explorer sidebar’s record (explorer.json, an object of key to text). The TypeScript side owns the settings shape, so the store keeps one opaque JSON object. Only a successful open is cached; a failed open is reported on every call and retried.

Implementations§

Source§

impl SettingsStore

Source

pub fn new(data_dir: Option<PathBuf>, namespace: impl Into<String>) -> Self

data_dir is the host’s per-user data directory (None when unavailable) and namespace the app’s folder name beneath it.

Source

pub fn in_app_folder(app_folder: PathBuf, namespace: impl Into<String>) -> Self

The store in the app’s own data folder, as rightkit-fs resolves it (AppDirs::data): settings.json and explorer.json live directly in app_folder, so the host keeps no parent-folder resolver of its own (viewright#57). namespace names the document schema.

Source

pub fn persisted_diagnostics_enabled(&self) -> bool

The diagnostics choice for the native log gate before the settings document is opened (early startup events): an absent or unreadable choice means on (the default).

Source

pub fn startup_diagnostics_enabled(&self) -> bool

Open the settings document and answer the diagnostics choice, so the opt-out is in force before the first native event. If the document cannot be opened, recording stays off.

Source

pub fn get( &self, key: &str, with_revision: Option<bool>, ) -> Result<Value, WorkspaceError>

Read a durable value. The SETTINGS_KEY key is the settings document (JSON string, or null when nothing has ever been saved). With with_revision, the document read answers { value, revision } where revision is the committed revision from the store (0 when nothing is stored). Other keys (the explorer record) read the explorer document.

Source

pub fn set( &self, key: &str, value: &str, expected_revision: Option<u64>, merge: Option<bool>, ) -> Result<SettingsWrite, WorkspaceError>

Persist a value: the settings document, or (any other key) the explorer document.

For the settings document, expected_revision makes the commit a compare-and-swap on the store’s committed revision (a stale one fails as a write conflict, nothing is written), and merge applies value as a top-level patch (null removes a key) inside the store’s write lock instead of replacing the whole document. The answer is { value, revision } with the committed document; other keys answer null.

Auto Trait Implementations§

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.