Struct Instance

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

Instance provides interface for the client to interact with the system: initiate and complete transaction, write and read data, etc.

Implementations§

Source§

impl Instance

Source

pub fn new(conf: ConfigMt) -> Result<Instance, Error>

Create a new instance with given configuration.

Source

pub fn initialize_datastore( path: &str, block_size: usize, desc_set: &[FileDesc], ) -> Result<(), Error>

Initialize datastore: create data, checkpoint, versioning store files, and lock file.

Source

pub fn add_datafile( &self, file_type: FileType, extent_size: u16, extent_num: u16, max_extent_num: u16, ) -> Result<u16, Error>

Add a new file to datastore and return it’s file_id.

Source

pub fn begin_transaction(&self) -> Result<Transaction<'_>, Error>

Begin a new transaction.

Source

pub fn commit(&self, t: Transaction<'_>) -> Result<(), Error>

Commit transaction.

Source

pub fn rollback(&self, t: Transaction<'_>) -> Result<(), Error>

Rollback transaction.

Source

pub fn open_read( &self, obj_id: &ObjectId, t: &Transaction<'_>, ) -> Result<Object<'_>, Error>

Open an existing object for read. After object is opened it is possible to read and seek through object’s data.

Source

pub fn open_write<'a>( &'a self, obj_id: &ObjectId, t: &'a mut Transaction<'_>, timeout: i64, ) -> Result<ObjectWrite<'_>, Error>

Open an existing object for modification by its id. After object is opened it is possible to read, write and seek through object data. This operation puts lock on the object which is released after transaction commit or rollback. If timeout is -1 then wait indefinitely, otherwise wait for requested time in ms before returning error, or until transaction holding lock on the object has finished.

Source

pub fn open_create<'a>( &'a self, file_id: u16, t: &'a mut Transaction<'_>, initial_size: usize, ) -> Result<ObjectWrite<'_>, Error>

Create a new object and open it for write. After object is opened it is possible to read, write and seek object data. This operation puts lock on the object which is released after transaction commit or rollback.

Source

pub fn delete( &self, obj_id: &ObjectId, t: &mut Transaction<'_>, timeout: i64, ) -> Result<(), Error>

Delete an object. If object is in use, timeout can be specified, and current transaction will wait given time until transaction holding the lock on the object has finished.

Source

pub fn from_shared_state(ss: InstanceSharedState) -> Result<Self, Error>

Build instance using shared state.

Source

pub fn get_shared_state(&self) -> Result<InstanceSharedState, Error>

Return shared state that can be shared between threads.

Source

pub fn terminate(self)

Terminate the instance. If several instances are running and sharing state then function has no effect for any of them but the last one. It is up to client to make sure all transactions are finished, otherwise unfinished transactions will be rolled back on the next start.

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, 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.