Public Key try_from_str
Signed-off-by: Luca Fulchir <luca.fulchir@runesauth.com>
This commit is contained in:
parent
342a58272c
commit
2c00e57bc6
|
@ -68,15 +68,30 @@ impl PublicKeyType {
|
|||
}
|
||||
}
|
||||
|
||||
impl TryFrom<&str> for PublicKeyType {
|
||||
type Error = ::std::io::Error;
|
||||
fn try_from(raw: &str) -> Result<Self, Self::Error> {
|
||||
if let Ok(type_u8) = raw.parse::<u8>() {
|
||||
if let Some(kind) = PublicKeyType::from_u8(type_u8) {
|
||||
return Ok(kind);
|
||||
}
|
||||
}
|
||||
return Err(::std::io::Error::new(
|
||||
::std::io::ErrorKind::InvalidData,
|
||||
"Public Key Type 0 is the only one supported",
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// Public Key, with its type and id
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct PublicKey {
|
||||
/// public key raw data
|
||||
raw: Vec<u8>,
|
||||
pub raw: Vec<u8>,
|
||||
/// type of public key
|
||||
kind: PublicKeyType,
|
||||
pub kind: PublicKeyType,
|
||||
/// id of public key
|
||||
id: PublicKeyId,
|
||||
pub id: PublicKeyId,
|
||||
}
|
||||
|
||||
impl PublicKey {
|
||||
|
@ -334,10 +349,10 @@ impl Address {
|
|||
#[derive(Debug, Clone)]
|
||||
pub struct Record {
|
||||
/// Public keys used by any authentication server
|
||||
public_keys: Vec<PublicKey>,
|
||||
pub public_keys: Vec<PublicKey>,
|
||||
/// List of all authentication servers' addresses.
|
||||
/// Multiple ones can point to the same authentication server
|
||||
addresses: Vec<Address>,
|
||||
pub addresses: Vec<Address>,
|
||||
}
|
||||
|
||||
impl Record {
|
||||
|
|
Loading…
Reference in New Issue