We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6dd74c9 commit 7342557Copy full SHA for 7342557
1 file changed
src/neighbour/state.rs
@@ -76,3 +76,26 @@ impl std::fmt::Display for NeighbourState {
76
}
77
78
79
+
80
+pub struct NeighbourStateParseError;
81
82
+impl std::str::FromStr for NeighbourState {
83
+ type Err = NeighbourStateParseError;
84
85
+ fn from_str(state: &str) -> Result<Self, Self::Err> {
86
+ let state = match state {
87
+ "incomplete" => Self::Incomplete,
88
+ "reachable" => Self::Reachable,
89
+ "stale" => Self::Stale,
90
+ "delay" => Self::Delay,
91
+ "probe" => Self::Probe,
92
+ "failed" => Self::Failed,
93
+ "noarp" => Self::Noarp,
94
+ "permanent" => Self::Permanent,
95
+ "none" => Self::None,
96
+ _ => return Err(NeighbourStateParseError),
97
+ };
98
99
+ Ok(state)
100
+ }
101
+}
0 commit comments