mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
handle construction results, separate index methods
This commit is contained in:
parent
e60a00c500
commit
611addda42
9 changed files with 105 additions and 40 deletions
|
|
@ -1,7 +1,9 @@
|
|||
mod database;
|
||||
mod error;
|
||||
mod gemini;
|
||||
|
||||
use database::Database;
|
||||
use error::Error;
|
||||
use gemini::Gemini;
|
||||
|
||||
use gtk::glib::DateTime;
|
||||
|
|
@ -18,7 +20,7 @@ impl Identity {
|
|||
// Constructors
|
||||
|
||||
/// Create new `Self`
|
||||
pub fn new(connection: Rc<RwLock<Connection>>, profile_id: Rc<i64>) -> Self {
|
||||
pub fn new(connection: Rc<RwLock<Connection>>, profile_id: Rc<i64>) -> Result<Self, Error> {
|
||||
// Init identity database
|
||||
let database = Rc::new(Database::new(connection.clone()));
|
||||
|
||||
|
|
@ -27,14 +29,21 @@ impl Identity {
|
|||
Some(identity) => identity.id,
|
||||
None => match database.add(profile_id, true, DateTime::now_local().unwrap(), None) {
|
||||
Ok(id) => id,
|
||||
Err(_) => todo!(),
|
||||
Err(_) => return Err(Error::Database),
|
||||
},
|
||||
});
|
||||
|
||||
Self {
|
||||
// Init gemini component
|
||||
let gemini = Rc::new(match Gemini::new(connection, profile_identity_id) {
|
||||
Ok(result) => result,
|
||||
Err(_) => return Err(Error::Gemini),
|
||||
});
|
||||
|
||||
// Done
|
||||
Ok(Self {
|
||||
// database,
|
||||
gemini: Rc::new(Gemini::new(connection, profile_identity_id)),
|
||||
}
|
||||
gemini,
|
||||
})
|
||||
}
|
||||
|
||||
/// Get `pem` record match `request`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue