Struct upm::database::Database
[−]
[src]
pub struct Database { pub sync_revision: u32, pub sync_url: String, pub sync_credentials: String, pub accounts: Vec<Account>, // some fields omitted }
This struct represents a UPM database, as read from a local file or a remote sync repository.
Fields
sync_revision: u32
sync_url: String
sync_credentials: String
accounts: Vec<Account>
Methods
impl Database
[src]
fn new() -> Database
Construct a fresh, empty database.
fn load_from_bytes(bytes: &[u8], password: &str) -> Result<Database, UpmError>
Load and decrypt a database from an in-memory byte slice using the provided password.
fn load_from_file<P: AsRef<Path>>(
filename: P,
password: &str
) -> Result<Database, UpmError>
filename: P,
password: &str
) -> Result<Database, UpmError>
Load and decrypt a database from the given filename using the provided password.
fn save(&self) -> Result<(), UpmError>
Save the database locally using the same filename previously used to load the database.
fn save_as(&self, filename: &Path, password: &str) -> Result<(), UpmError>
Save the database locally using the provided filename and password.
fn save_raw_bytes<P: AsRef<Path>>(
bytes: Vec<u8>,
filename: P
) -> Result<(), UpmError>
bytes: Vec<u8>,
filename: P
) -> Result<(), UpmError>
Save an already-encoded database locally using the provided filename.
fn save_to_bytes(&self, password: &str) -> Result<Vec<u8>, UpmError>
Save the database to an in-memory byte buffer. This is useful, for example, when sending the database to a remote sync repository.
fn account(&self, name: &str) -> Option<&Account>
Return a reference to the named account.
fn account_mut(&mut self, name: &str) -> Option<&mut Account>
Return a mutable reference to the named account.
fn contains(&self, name: &str) -> bool
Return true if the database contains an account with the specified name; otherwise return false.
fn update_account(
&mut self,
name: &str,
new_account: &Account
) -> Result<(), UpmError>
&mut self,
name: &str,
new_account: &Account
) -> Result<(), UpmError>
Update the named account with the fields in the provided account object. The account object may contain a new account name for this account.
fn add_account(&mut self, new_account: &Account) -> Result<(), UpmError>
Add a copy of the provided account object to the database as a new account.
fn delete_account(&mut self, name: &str)
Delete the specified account from the database.
fn has_remote(&self) -> bool
Return true if this database has a remote sync repository configured; otherwise return false.
fn set_path<P: AsRef<Path>>(&mut self, path: &P) -> Result<(), UpmError>
Set the path of the local database to the specified path.
fn path(&self) -> Option<&Path>
Return the path to the local database, if known.
fn name(&self) -> Option<&str>
Return the name of the database, if available. The name is the final path component of the database in the local filesystem.
fn path_to_name<P: AsRef<Path>>(path: &P) -> Result<&str, UpmError>
Return the name of a database that is represented by the provided filesystem path.
fn set_password<P: AsRef<str>>(&mut self, password: &P)
Set the password used to encrypt this database.
fn password(&self) -> Option<&str>
Retrieve the password used to encrypt and decrypt this database.
fn set_synced(&mut self)
Mark the database as being synchronized with the remote sync repository. This is only valid for 5 minutes.
fn clear_synced(&mut self)
Mark the database as not being synchronized with the remote sync repository.
fn is_synced(&self) -> bool
Return true if the database is synchronized with the remote sync repository; otherwise return false.
Trait Implementations
impl Clone for Database
[src]
fn clone(&self) -> Database
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more