mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 09:35:28 +00:00
enshort to common variable name
This commit is contained in:
parent
dd5fada7c7
commit
293c7d0aa3
15 changed files with 69 additions and 69 deletions
|
|
@ -59,7 +59,7 @@ impl Database {
|
|||
// Done
|
||||
match tx.commit() {
|
||||
Ok(_) => Ok(id),
|
||||
Err(reason) => Err(reason),
|
||||
Err(e) => Err(e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@ pub enum Error {
|
|||
impl Display for Error {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result {
|
||||
match self {
|
||||
Self::Database(reason) => {
|
||||
write!(f, "Database error: {reason}")
|
||||
Self::Database(e) => {
|
||||
write!(f, "Database error: {e}")
|
||||
}
|
||||
Self::Gemini(reason) => {
|
||||
write!(f, "Could not init Gemini identity: {reason}")
|
||||
Self::Gemini(e) => {
|
||||
write!(f, "Could not init Gemini identity: {e}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ impl Gemini {
|
|||
// Init components
|
||||
let auth = match Auth::new(connection.clone()) {
|
||||
Ok(auth) => Rc::new(auth),
|
||||
Err(reason) => return Err(Error::Auth(reason)),
|
||||
Err(e) => return Err(Error::Auth(e)),
|
||||
};
|
||||
let database = Rc::new(Database::new(connection, profile_identity_id.clone()));
|
||||
let memory = Rc::new(Memory::new());
|
||||
|
|
@ -64,7 +64,7 @@ impl Gemini {
|
|||
self.index()?;
|
||||
Ok(profile_identity_gemini_id)
|
||||
}
|
||||
Err(reason) => Err(Error::Database(reason)),
|
||||
Err(e) => Err(Error::Database(e)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ impl Gemini {
|
|||
self.index()?;
|
||||
Ok(())
|
||||
}
|
||||
Err(reason) => Err(Error::Database(reason)),
|
||||
Err(e) => Err(Error::Database(e)),
|
||||
},
|
||||
Err(e) => Err(Error::Auth(e)),
|
||||
}
|
||||
|
|
@ -97,27 +97,27 @@ impl Gemini {
|
|||
name,
|
||||
) {
|
||||
Ok(pem) => self.add(&pem),
|
||||
Err(reason) => Err(Error::Certificate(reason)),
|
||||
Err(e) => Err(Error::Certificate(e)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Create new `Memory` index from `Database` for `Self`
|
||||
pub fn index(&self) -> Result<(), Error> {
|
||||
// Clear previous records
|
||||
if let Err(reason) = self.memory.clear() {
|
||||
return Err(Error::Memory(reason));
|
||||
if let Err(e) = self.memory.clear() {
|
||||
return Err(Error::Memory(e));
|
||||
}
|
||||
|
||||
// Build new index
|
||||
match self.database.records() {
|
||||
Ok(records) => {
|
||||
for record in records {
|
||||
if let Err(reason) = self.memory.add(record.id, record.pem) {
|
||||
return Err(Error::Memory(reason));
|
||||
if let Err(e) = self.memory.add(record.id, record.pem) {
|
||||
return Err(Error::Memory(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(reason) => return Err(Error::Database(reason)),
|
||||
Err(e) => return Err(Error::Database(e)),
|
||||
};
|
||||
|
||||
Ok(())
|
||||
|
|
@ -135,7 +135,7 @@ impl Gemini {
|
|||
pem,
|
||||
});
|
||||
}
|
||||
Err(reason) => todo!("{:?}", reason.to_string()),
|
||||
Err(e) => todo!("{:?}", e.to_string()),
|
||||
}
|
||||
}
|
||||
None
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ impl Auth {
|
|||
let profile_identity_gemini_auth_id =
|
||||
match self.database.add(profile_identity_gemini_id, scope) {
|
||||
Ok(id) => id,
|
||||
Err(reason) => return Err(Error::Database(reason)),
|
||||
Err(e) => return Err(Error::Database(e)),
|
||||
};
|
||||
|
||||
// Reindex
|
||||
|
|
@ -64,12 +64,12 @@ impl Auth {
|
|||
match self.database.records_scope(Some(scope)) {
|
||||
Ok(records) => {
|
||||
for record in records {
|
||||
if let Err(reason) = self.database.delete(record.id) {
|
||||
return Err(Error::Database(reason));
|
||||
if let Err(e) = self.database.delete(record.id) {
|
||||
return Err(Error::Database(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(reason) => return Err(Error::Database(reason)),
|
||||
Err(e) => return Err(Error::Database(e)),
|
||||
}
|
||||
self.index()?;
|
||||
Ok(())
|
||||
|
|
@ -80,12 +80,12 @@ impl Auth {
|
|||
match self.database.records_ref(profile_identity_gemini_id) {
|
||||
Ok(records) => {
|
||||
for record in records {
|
||||
if let Err(reason) = self.database.delete(record.id) {
|
||||
return Err(Error::Database(reason));
|
||||
if let Err(e) = self.database.delete(record.id) {
|
||||
return Err(Error::Database(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(reason) => return Err(Error::Database(reason)),
|
||||
Err(e) => return Err(Error::Database(e)),
|
||||
}
|
||||
self.index()?;
|
||||
Ok(())
|
||||
|
|
@ -94,23 +94,23 @@ impl Auth {
|
|||
/// Create new `Memory` index from `Database` for `Self`
|
||||
pub fn index(&self) -> Result<(), Error> {
|
||||
// Clear previous records
|
||||
if let Err(reason) = self.memory.clear() {
|
||||
return Err(Error::Memory(reason));
|
||||
if let Err(e) = self.memory.clear() {
|
||||
return Err(Error::Memory(e));
|
||||
}
|
||||
|
||||
// Build new index
|
||||
match self.database.records_scope(None) {
|
||||
Ok(records) => {
|
||||
for record in records {
|
||||
if let Err(reason) = self
|
||||
if let Err(e) = self
|
||||
.memory
|
||||
.add(record.scope, record.profile_identity_gemini_id)
|
||||
{
|
||||
return Err(Error::Memory(reason));
|
||||
return Err(Error::Memory(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(reason) => return Err(Error::Database(reason)),
|
||||
Err(e) => return Err(Error::Database(e)),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ impl Database {
|
|||
// Done
|
||||
match tx.commit() {
|
||||
Ok(_) => Ok(id),
|
||||
Err(reason) => Err(reason),
|
||||
Err(e) => Err(e),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ impl Database {
|
|||
// Done
|
||||
match tx.commit() {
|
||||
Ok(_) => Ok(()),
|
||||
Err(reason) => Err(reason),
|
||||
Err(e) => Err(e),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ pub enum Error {
|
|||
impl Display for Error {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result {
|
||||
match self {
|
||||
Self::Database(reason) => write!(f, "Database error: {reason}"),
|
||||
Self::Memory(reason) => write!(f, "Memory error: {reason}"),
|
||||
Self::Database(e) => write!(f, "Database error: {e}"),
|
||||
Self::Memory(e) => write!(f, "Memory error: {e}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ impl Database {
|
|||
// Done
|
||||
match tx.commit() {
|
||||
Ok(_) => Ok(id),
|
||||
Err(reason) => Err(reason),
|
||||
Err(e) => Err(e),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -57,7 +57,7 @@ impl Database {
|
|||
// Done
|
||||
match tx.commit() {
|
||||
Ok(_) => Ok(()),
|
||||
Err(reason) => Err(reason),
|
||||
Err(e) => Err(e),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ impl Identity {
|
|||
pub fn to_tls_certificate(&self) -> Result<TlsCertificate, Error> {
|
||||
match TlsCertificate::from_pem(&self.pem) {
|
||||
Ok(certificate) => Ok(certificate),
|
||||
Err(reason) => Err(Error::TlsCertificate(reason)),
|
||||
Err(e) => Err(Error::TlsCertificate(e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue