Struct crio::Client

source · []
pub struct Client<T: Serialize + DeserializeOwned> { /* private fields */ }
Expand description

An object that is responsible for handling IO operations with regards to file opening/closing/writing as well as serialization and deserialization. The main data type of this crate.

Implementations

Creates a new client object. It opens a file if a file with the same name exists or creates a new file if it doesn’t exist. Set the append parameter to false if you want to overwrite all data while calling write() or write_many(), or true if you simply want to append data to the file.

Errors
  • The usual std::io::Error if it fails to open or create a new file.

Returns a vector of the deserialized object. If the file is empty, this method returns Ok(None).

Errors
  • If a checksum mismatch occurs, a DataPoisonError<T> is returned, in which you can get the underlying deserialized objects via the method into_inner().

  • bincode::Error occurs if the deserializer fails to deserialize bytes from the file to your requested object. In that case, the most probable reason is that the data in that file stores some other data type and you are attempting to deserialize it to the wrong data type.

  • The usual std::io::Error such as ErrorKind::UnexpectedEof if the file that is being accessed is malformed and there are no more bytes to be read when the method is expecting more data.

Writes the provided serializable objects to disk. If no file is found, a new file will be created and written to.

Errors
  • std::num::TryFromIntError occurs when an object you are inserting takes up more space than u32::MAX bytes. In that case, seek help.

  • The usual std::io::Error such as ErrorKind::UnexpectedEof if the file that is being accessed is malformed and there are no more bytes to be read when the method is expecting more data.

  • Serialization errors when the data provided fails to serialize for some reason.

Writes the provided serializable object to disk. If no file is found, a new file will be created and written to.

Errors
  • DatabaseError<T>::DataTooLarge occurs when an object you are inserting takes up more space than u32::MAX bytes. In that case, seek help.

  • The usual std::io::Error such as ErrorKind::UnexpectedEof if the file that is being accessed is malformed and there are no more bytes to be read when the method is expecting more data.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.