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
impl Instance
Sourcepub fn new(conf: ConfigMt) -> Result<Instance, Error>
pub fn new(conf: ConfigMt) -> Result<Instance, Error>
Create a new instance with given configuration.
Sourcepub fn initialize_datastore(
path: &str,
block_size: usize,
desc_set: &[FileDesc],
) -> Result<(), Error>
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.
Sourcepub fn add_datafile(
&self,
file_type: FileType,
extent_size: u16,
extent_num: u16,
max_extent_num: u16,
) -> Result<u16, Error>
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.
Sourcepub fn begin_transaction(&self) -> Result<Transaction<'_>, Error>
pub fn begin_transaction(&self) -> Result<Transaction<'_>, Error>
Begin a new transaction.
Sourcepub fn open_read(
&self,
obj_id: &ObjectId,
t: &Transaction<'_>,
) -> Result<Object<'_>, Error>
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.
Sourcepub fn open_write<'a>(
&'a self,
obj_id: &ObjectId,
t: &'a mut Transaction<'_>,
timeout: i64,
) -> Result<ObjectWrite<'_>, Error>
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.
Sourcepub fn open_create<'a>(
&'a self,
file_id: u16,
t: &'a mut Transaction<'_>,
initial_size: usize,
) -> Result<ObjectWrite<'_>, Error>
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.
Sourcepub fn delete(
&self,
obj_id: &ObjectId,
t: &mut Transaction<'_>,
timeout: i64,
) -> Result<(), Error>
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.
Build instance using shared state.
Return shared state that can be shared between threads.
Sourcepub fn terminate(self)
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.