use Algorithm;
use base64;
use ring;
use serde_json;
use std::{self, fmt};
pub enum TwistJwt {
Base64(base64::Base64Error),
InvalidAlgorithm(Algorithm),
InvalidToken,
Io(std::io::Error),
Json(serde_json::Error),
Ring(ring::error::Unspecified),
}
impl fmt::Display for TwistJwt {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
TwistJwt::Base64(ref e) => write!(f, "{}", e),
TwistJwt::InvalidAlgorithm(ref a) => write!(f, "{}", a),
TwistJwt::InvalidToken => write!(f, "Invalid Token"),
TwistJwt::Io(ref e) => write!(f, "{}", e),
TwistJwt::Json(ref e) => write!(f, "{}", e),
TwistJwt::Ring(ref e) => write!(f, "{}", e),
}
}
}
impl From<base64::Base64Error> for TwistJwt {
fn from(err: base64::Base64Error) -> TwistJwt {
TwistJwt::Base64(err)
}
}
impl From<std::io::Error> for TwistJwt {
fn from(err: std::io::Error) -> TwistJwt {
TwistJwt::Io(err)
}
}
impl From<ring::error::Unspecified> for TwistJwt {
fn from(err: ring::error::Unspecified) -> TwistJwt {
TwistJwt::Ring(err)
}
}
impl From<serde_json::Error> for TwistJwt {
fn from(err: serde_json::Error) -> TwistJwt {
TwistJwt::Json(err)
}
}