[−][src]Struct tslite::PhysicalDB
a DB in file
Fields
path: PathBuf
file: Option<File>
header: DbHeader
Implementations
impl PhysicalDB
[src]
pub fn new(
path: &Path,
origin_date: Option<DateTime<Utc>>
) -> Result<PhysicalDB, TSLiteError>
[src]
path: &Path,
origin_date: Option<DateTime<Utc>>
) -> Result<PhysicalDB, TSLiteError>
This function will create a new database file or open it if it already exists.
The second argument the date with which to initialize the database. It is optional, if you give None
it will use the current date and time. If the file exists, the date is ignored complitely.
pub fn create(
path: &Path,
origin_date: Option<DateTime<Utc>>
) -> Result<PhysicalDB, TSLiteError>
[src]
path: &Path,
origin_date: Option<DateTime<Utc>>
) -> Result<PhysicalDB, TSLiteError>
This function will create a new database file.
Warning: It will not check if there is already a file at path
, if there is one, it will be overwritten.
The second argument the date with which to initialize the database. It is optional, if you give None
it will use the current date and time.
pub fn open(&mut self) -> Result<(), TSLiteError>
[src]
Open the database file in read and write mode.
pub fn close(&mut self) -> Result<(), TSLiteError>
[src]
Drop the database file to close it. Make sure to sync all IO operation before closing it.
pub fn read_header(&mut self) -> Result<DbHeader, TSLiteError>
[src]
Read the header from the file. Does not update the header in memory.
pub fn read_record(&mut self, rec_id: u64) -> Result<RecordInfo, TSLiteError>
[src]
The size of the header and record are static.
So the position of each record is deterministic.
If n
is the record id, then its position within the file can be computed with :
pos(n) = (7 + 8) + (5*n)
pub fn update_record_number(&mut self, drn: u64) -> Result<(), TSLiteError>
[src]
This utility function will update the number of record in the database.
pub fn append_record(&mut self, rec_nfo: RecordInfo) -> Result<(), TSLiteError>
[src]
Add a record in the database.
pub fn append_record_now(&mut self, value: u8) -> Result<(), TSLiteError>
[src]
Append a record with the current time.
pub fn update_record(
&mut self,
rec_id: u64,
value: u8
) -> Result<(), TSLiteError>
[src]
&mut self,
rec_id: u64,
value: u8
) -> Result<(), TSLiteError>
Change the value of a record within the database.
pub fn check_db_file(&mut self) -> Result<DbIssue, TSLiteError>
[src]
Perform check to find any issue in the database file.
It will return the first issue it find. You might need to run this function
until it return DbIssue::None
to check for all possible issue.
pub fn reorder_record(&mut self) -> Result<(), TSLiteError>
[src]
Reorder the record in the DB. Use if your DB records got scrambled for some reason. Right now it use a simple way :
- Read all the record
- reorder them in-memory
- dump all the record in the DB It means that if you have just one record wrong you end up re-writing the whole DB.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for PhysicalDB
impl Send for PhysicalDB
impl Sync for PhysicalDB
impl Unpin for PhysicalDB
impl UnwindSafe for PhysicalDB
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,