mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
implement to_tls_certificate method
This commit is contained in:
parent
ba9a679303
commit
9f23e9e51d
3 changed files with 31 additions and 2 deletions
|
|
@ -1,4 +1,18 @@
|
|||
mod error;
|
||||
use error::Error;
|
||||
|
||||
use gtk::gio::TlsCertificate;
|
||||
|
||||
pub struct Identity {
|
||||
pub pem: String,
|
||||
// pub scope: String,
|
||||
}
|
||||
|
||||
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)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
15
src/profile/identity/gemini/identity/error.rs
Normal file
15
src/profile/identity/gemini/identity/error.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
use gtk::glib;
|
||||
use std::fmt::{Display, Formatter, Result};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
TlsCertificate(glib::Error),
|
||||
}
|
||||
|
||||
impl Display for Error {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result {
|
||||
match self {
|
||||
Self::TlsCertificate(e) => write!(f, "TLS certificate error: {e}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue