Skip to content

Commit

Permalink
fix: hasheable user agent
Browse files Browse the repository at this point in the history
  • Loading branch information
heilhead committed Feb 24, 2024
1 parent be9d7b2 commit 6588932
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions relay_rpc/src/user_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub enum ParsingError {
///
/// [`UserAgent`] will only fail to parse an empty string. Otherwise the result
/// will be either a [`ValidUserAgent`] or an unknown user agent string.
#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone, Hash, Eq, PartialEq)]
pub enum UserAgent {
Unknown(String),
ValidUserAgent(ValidUserAgent),
Expand All @@ -46,34 +46,34 @@ pub enum UserAgent {
/// Represents a valid (parsed) user agent.
///
/// Succeeds in parsing only if all of its parts are successfully parsed.
#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone, Hash, Eq, PartialEq)]
pub struct ValidUserAgent {
pub protocol: Protocol,
pub sdk: Sdk,
pub os: OsInfo,
pub id: Option<Id>,
}

#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone, Hash, Eq, PartialEq)]
pub struct OsInfo {
pub os_family: String,
pub ua_family: Option<String>,
pub version: Option<String>,
}

#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone, Hash, Eq, PartialEq)]
pub enum ProtocolKind {
WalletConnect,
Unknown(String),
}

#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone, Hash, Eq, PartialEq)]
pub struct Protocol {
pub kind: ProtocolKind,
pub version: u32,
}

#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone, Hash, Eq, PartialEq)]
pub enum SdkLanguage {
Js,
Swift,
Expand All @@ -83,13 +83,13 @@ pub enum SdkLanguage {
Unknown(String),
}

#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone, Hash, Eq, PartialEq)]
pub struct Sdk {
pub language: SdkLanguage,
pub version: String,
}

#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone, Hash, Eq, PartialEq)]
pub enum Environment {
Browser,
ReactNative,
Expand All @@ -99,7 +99,7 @@ pub enum Environment {
Unknown(String),
}

#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone, Hash, Eq, PartialEq)]
pub struct Id {
pub environment: Environment,
pub host: Option<String>,
Expand Down

0 comments on commit 6588932

Please sign in to comment.