1use std::str::FromStr;
2use std::path::PathBuf;
3use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr};
4
5use super::FromCommandLine;
6
7
8impl FromCommandLine for PathBuf {
9 fn from_argument(s: &str) -> Result<Self, String> {
10 Ok(From::from(s))
11 }
12}
13
14impl FromCommandLine for f32 {
15 fn from_argument(s: &str) -> Result<Self, String> {
16 FromStr::from_str(s).map_err(|e| format!("{:?}", e))
17 }
18}
19impl FromCommandLine for f64 {
20 fn from_argument(s: &str) -> Result<Self, String> {
21 FromStr::from_str(s).map_err(|e| format!("{:?}", e))
22 }
23}
24
25impl FromCommandLine for isize {
27 fn from_argument(s: &str) -> Result<Self, String> {
28 FromStr::from_str(s).map_err(|e| format!("{:?}", e))
29 }
30}
31impl FromCommandLine for i8 {
32 fn from_argument(s: &str) -> Result<Self, String> {
33 FromStr::from_str(s).map_err(|e| format!("{:?}", e))
34 }
35}
36impl FromCommandLine for i16 {
37 fn from_argument(s: &str) -> Result<Self, String> {
38 FromStr::from_str(s).map_err(|e| format!("{:?}", e))
39 }
40}
41impl FromCommandLine for i32 {
42 fn from_argument(s: &str) -> Result<Self, String> {
43 FromStr::from_str(s).map_err(|e| format!("{:?}", e))
44 }
45}
46impl FromCommandLine for i64 {
47 fn from_argument(s: &str) -> Result<Self, String> {
48 FromStr::from_str(s).map_err(|e| format!("{:?}", e))
49 }
50}
51impl FromCommandLine for usize {
52 fn from_argument(s: &str) -> Result<Self, String> {
53 FromStr::from_str(s).map_err(|e| format!("{:?}", e))
54 }
55}
56impl FromCommandLine for u8 {
57 fn from_argument(s: &str) -> Result<Self, String> {
58 FromStr::from_str(s).map_err(|e| format!("{:?}", e))
59 }
60}
61impl FromCommandLine for u16 {
62 fn from_argument(s: &str) -> Result<Self, String> {
63 FromStr::from_str(s).map_err(|e| format!("{:?}", e))
64 }
65}
66impl FromCommandLine for u32 {
67 fn from_argument(s: &str) -> Result<Self, String> {
68 FromStr::from_str(s).map_err(|e| format!("{:?}", e))
69 }
70}
71impl FromCommandLine for u64 {
72 fn from_argument(s: &str) -> Result<Self, String> {
73 FromStr::from_str(s).map_err(|e| format!("{:?}", e))
74 }
75}
76impl FromCommandLine for bool {
77 fn from_argument(s: &str) -> Result<Self, String> {
78 FromStr::from_str(s).map_err(|e| format!("{:?}", e))
79 }
80}
81impl FromCommandLine for String {
82 fn from_argument(s: &str) -> Result<Self, String> {
83 FromStr::from_str(s).map_err(|_| unreachable!())
84 }
85}
86impl FromCommandLine for Ipv4Addr {
87 fn from_argument(s: &str) -> Result<Self, String> {
88 FromStr::from_str(s).map_err(|e| format!("{:?}", e))
89 }
90}
91impl FromCommandLine for Ipv6Addr {
92 fn from_argument(s: &str) -> Result<Self, String> {
93 FromStr::from_str(s).map_err(|e| format!("{:?}", e))
94 }
95}
96impl FromCommandLine for SocketAddr {
97 fn from_argument(s: &str) -> Result<Self, String> {
98 FromStr::from_str(s).map_err(|e| format!("{:?}", e))
99 }
100}