Struct workspace2::WorkspaceDb

source ·
pub struct WorkspaceDb(_);

Implementations§

source§

impl WorkspaceDb

source

pub fn workspace_for_roots<P: AsRef<Path>>( &self, worktree_roots: &[P] ) -> Option<SerializedWorkspace>

Returns a serialized workspace for the given worktree_roots. If the passed array is empty, the most recent workspace is returned instead. If no workspace for the passed roots is stored, returns none.

source

pub async fn save_workspace(&self, workspace: SerializedWorkspace)

Saves a workspace using the worktree roots. Will garbage collect any workspaces that used this workspace previously

source

pub async fn next_id(&self) -> Result<WorkspaceId>

source

pub async fn recent_workspaces_on_disk( &self ) -> Result<Vec<(WorkspaceId, WorkspaceLocation)>>

source

pub async fn last_workspace(&self) -> Result<Option<WorkspaceLocation>>

source

pub async fn update_timestamp(&self, workspace_id: WorkspaceId) -> Result<()>

source

pub async fn set_window_bounds( &self, workspace_id: WorkspaceId, bounds: WindowBounds, display: Uuid ) -> Result<()>

Methods from Deref<Target = ThreadSafeConnection<WorkspaceDb>>§

pub fn write<T>( &self, callback: impl Send + FnOnce(&Connection) -> T + 'static ) -> impl Future<Output = T>where T: 'static + Send + Sync,

Methods from Deref<Target = Connection>§

pub fn persistent(&self) -> bool

pub fn can_write(&self) -> bool

pub fn backup_main(&self, destination: &Connection) -> Result<(), Error>

pub fn backup_main_to(&self, destination: impl AsRef<Path>) -> Result<(), Error>

pub fn sql_has_syntax_error(&self, sql: &str) -> Option<(String, usize)>

pub fn migrate( &self, domain: &'static str, migrations: &[&'static str] ) -> Result<(), Error>

Migrate the database, for the given domain. Note: Unlike everything else in SQLez, migrations are run eagerly, without first preparing the SQL statements. This makes it possible to do multi-statement schema updates in a single string without running into prepare errors.

pub fn with_savepoint<R, F>( &self, name: impl AsRef<str>, f: F ) -> Result<R, Error>where F: FnOnce() -> Result<R, Error>,

pub fn with_savepoint_rollback<R, F>( &self, name: impl AsRef<str>, f: F ) -> Result<Option<R>, Error>where F: FnOnce() -> Result<Option<R>, Error>,

pub fn exec<'a>(&'a self, query: &str) -> Result<impl FnMut() + 'a, Error>

Prepare a statement which has no bindings and returns nothing.

Note: If there are multiple statements that depend upon each other (such as those which make schema changes), preparation will fail. Use a true migration instead.

pub fn exec_bound<B, 'a>( &'a self, query: &str ) -> Result<impl FnMut(B) + 'a, Error>where B: Bind,

Prepare a statement which takes a binding, but returns nothing. The bindings for a given invocation should be passed to the returned closure

Note: If there are multiple statements that depend upon each other (such as those which make schema changes), preparation will fail. Use a true migration instead.

pub fn select<C, 'a>(&'a self, query: &str) -> Result<impl FnMut() + 'a, Error>where C: Column,

Prepare a statement which has no bindings and returns a Vec<C>.

Note: If there are multiple statements that depend upon each other (such as those which make schema changes), preparation will fail. Use a true migration instead.

pub fn select_bound<B, C, 'a>( &'a self, query: &str ) -> Result<impl FnMut(B) + 'a, Error>where B: Bind, C: Column,

Prepare a statement which takes a binding and returns a Vec<C>.

Note: If there are multiple statements that depend upon each other (such as those which make schema changes), preparation will fail. Use a true migration instead.

pub fn select_row<C, 'a>( &'a self, query: &str ) -> Result<impl FnMut() + 'a, Error>where C: Column,

Prepare a statement that selects a single row from the database. Will return none if no rows are returned and will error if more than 1 row

Note: If there are multiple statements that depend upon each other (such as those which make schema changes), preparation will fail. Use a true migration instead.

pub fn select_row_bound<B, C, 'a>( &'a self, query: &str ) -> Result<impl FnMut(B) + 'a, Error>where B: Bind, C: Column,

Prepare a statement which takes a binding and selects a single row from the database. WIll return none if no rows are returned and will error if more than 1 row is returned.

Note: If there are multiple statements that depend upon each other (such as those which make schema changes), preparation will fail. Use a true migration instead.

Trait Implementations§

source§

impl Deref for WorkspaceDb

§

type Target = ThreadSafeConnection<WorkspaceDb>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl Domain for WorkspaceDb

source§

fn name() -> &'static str

source§

fn migrations() -> &'static [&'static str]

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere 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.

§

impl<D> Migrator for Dwhere D: Domain,

§

fn migrate(connection: &Connection) -> Result<(), Error>

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
§

impl<T, U> ToSample<U> for Twhere U: FromSample<T>,

§

fn to_sample_(self) -> U

source§

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

§

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 Twhere U: TryFrom<T>,

§

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<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<S, T> Duplex<S> for Twhere T: FromSample<S> + ToSample<S>,