[][src]Struct simplebase::engine::RecordData

pub struct RecordData {
    pub location: usize,
    pub location_type: u8,
    pub hash_data: HashMap<usize, RecordCharacteristics>,
    pub record_counter: usize,
    pub data_base: String,
}

Fields

location: usizelocation_type: u8hash_data: HashMap<usize, RecordCharacteristics>record_counter: usizedata_base: String

Methods

impl RecordData[src]

pub fn add_record_with_key<T>(&mut self, key_to_add: String, record: T) where
    T: Base
[src]

This method adds information to the database with a key as well.

Examples

use simplebase::engine::*;
let mut loaded_database = load_hash_database("test1base.txt");
loaded_database.add_record_with_key("mob".to_string(), "0404111222".to_string());

pub fn add_record_with_key_exclusive<T>(
    &mut self,
    key_to_add: String,
    record: T
) -> bool where
    T: Base
[src]

This method adds information to the database with a key as well. If the key already exists in the database, the information will not be added. The method returns true if successful, false, if they key exists already in the database.

Examples

use simplebase::engine::*;
let mut loaded_database = load_hash_database("test1base.txt");
loaded_database.add_record_with_key_exclusive("mob".to_string(), "0404111222".to_string());

pub fn add_record<T>(&mut self, record: T) where
    T: Base
[src]

This method adds information to the database.

Examples

use simplebase::engine::*;
let mut loaded_database = load_hash_database("test1base.txt");
loaded_database.add_record("0404111222".to_string());

pub fn delete_record(&mut self, record_number: usize)[src]

This method deletes a record based on the supplied record number. If the record does not exist, it does nothing.

Examples

use simplebase::engine::*;
let mut database = load_hash_database("test1base.txt");
database.delete_record(1);
database.delete_record(1000000); //This will do nothing since the 1000000 record does not exist.

pub fn find(&self, what_to_find: &str) -> Vec<String>[src]

Searches the database for a particular term and returns the matching record in a String vector consisting of two values for each match 1) The record id 2) The contents of the matching record. This method is available on read only databases (all methods work on writeable databases).

Examples

use simplebase::engine::*;
let loaded_database = load_hash_database("test1base.txt");
let found_records = loaded_database.find("great");

pub fn find_key(&self, what_to_find: &str) -> Vec<String>[src]

Searches the database key values (if a key value exists for a record- key values are optional) for a particular term and returns the matching record in a String vector consisting of two values for each match 1) The record id 2) The contents of the matching record. This method is available on read only databases (all methods work on writeable databases).

Examples

use simplebase::engine::*;
let loaded_database = load_hash_database("test1base.txt");
let found_records = loaded_database.find_key("great");

pub fn get_record(&self, record_number: usize) -> Option<String>[src]

This method returns a record. It returns None if the record does not exist. This is also available if a database is opened using the load_hash_database_read_only method.

Examples

use simplebase::engine::*;
let loaded_database = load_hash_database("test1base.txt");
let particular_record = loaded_database.get_record(1);

pub fn length(&self) -> usize[src]

This function returns the number of records stored in the database

Examples

use simplebase::engine::*;
let mut database = load_hash_database("test1base.txt");
database.length();

pub fn return_data_type(&self, record_number: usize) -> u8[src]

This function returns the data type (e.g String, u64, f64 etc) of a stored value. This is based on the DataType enum.

Examples

use simplebase::engine::*;
let mut database = load_hash_database("test1base.txt");
database.return_data_type(1);

pub fn save_database(&self, filename: &str)[src]

Saves a database hash table to a file. This will need to be run to save the database to a file. It is up to the user to impliment this action.

Examples

use simplebase::engine::*;
let database = load_hash_database("test1base.txt");
database.save_database("test1base.txt");

pub fn verify_record(&self, record_number: usize) -> bool[src]

Calculates a simple chksum on the contents of a record and compares it to the stored chksum. This will return false if there is a mismatch. If the record does not exist, it will still return true.

Examples

use simplebase::engine::*;
let mut database = new_empty_database();
database.add_record_with_key_exclusive("mob".to_string(), "0404111222".to_string());
let result = database.verify_record(1);
assert_eq!(true,result);

pub fn verify_database(&self) -> usize[src]

Checks the checksum in the database for each record. If it does not match, a message is printed stated which record has potentially being corrupted. It also returns the amount of corrupted records if there are any. If zero is returned this means that there are no corrupted records.

Examples

use simplebase::engine::*;
let loaded_database = load_hash_database("test1base.txt");
loaded_database.verify_database();

Trait Implementations

impl Default for RecordData[src]

impl Debug for RecordData[src]

Auto Trait Implementations

impl Send for RecordData

impl Sync for RecordData

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]