solana: add FromStr for cluster
This commit is contained in:
parent
78e274164a
commit
c336079b05
|
@ -62,6 +62,19 @@ pub enum Cluster {
|
||||||
Mainnet,
|
Mainnet,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::str::FromStr for Cluster {
|
||||||
|
type Err = &'static str;
|
||||||
|
|
||||||
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
|
match s {
|
||||||
|
"devnet" => Ok(Self::Devnet),
|
||||||
|
"testnet" => Ok(Self::Testnet),
|
||||||
|
"mainnet" => Ok(Self::Mainnet),
|
||||||
|
_ => Err("Invalid value"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for Cluster {
|
impl std::fmt::Display for Cluster {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
|
|
Loading…
Reference in New Issue