Struct Networks

Source
pub struct Networks { /* private fields */ }
Expand description

Interacting with network interfaces.

use sysinfo::Networks;

let networks = Networks::new_with_refreshed_list();
for (interface_name, network) in &networks {
    println!("[{interface_name}]: {network:?}");
}

Implementations§

Source§

impl Networks

Source

pub fn new() -> Self

Creates a new empty Networks type.

If you want it to be filled directly, take a look at Networks::new_with_refreshed_list.

use sysinfo::Networks;

let mut networks = Networks::new();
networks.refresh(true);
for (interface_name, network) in &networks {
    println!("[{interface_name}]: {network:?}");
}
Source

pub fn new_with_refreshed_list() -> Self

Creates a new Networks type with the network interfaces list loaded.

use sysinfo::Networks;

let networks = Networks::new_with_refreshed_list();
for network in &networks {
    println!("{network:?}");
}
Examples found in repository?
examples/simple.rs (line 341)
338fn main() {
339    println!("Getting system information...");
340    let mut system = System::new_all();
341    let mut networks = Networks::new_with_refreshed_list();
342    let mut disks = Disks::new_with_refreshed_list();
343    let mut components = Components::new_with_refreshed_list();
344    let mut users = Users::new_with_refreshed_list();
345
346    println!("Done.");
347    let t_stin = io::stdin();
348    let mut stin = t_stin.lock();
349    let mut done = false;
350
351    println!("To get the commands' list, enter 'help'.");
352    while !done {
353        let mut input = String::new();
354        write!(&mut io::stdout(), "> ");
355        io::stdout().flush();
356
357        stin.read_line(&mut input);
358        if input.is_empty() {
359            // The string is empty, meaning there is no '\n', meaning
360            // that the user used CTRL+D so we can just quit!
361            println!("\nLeaving, bye!");
362            break;
363        }
364        if (&input as &str).ends_with('\n') {
365            input.pop();
366        }
367        done = interpret_input(
368            input.as_ref(),
369            &mut system,
370            &mut networks,
371            &mut disks,
372            &mut components,
373            &mut users,
374        );
375    }
376}
Source

pub fn list(&self) -> &HashMap<String, NetworkData>

Returns the network interfaces map.

use sysinfo::Networks;

let networks = Networks::new_with_refreshed_list();
for network in networks.list() {
    println!("{network:?}");
}
Source

pub fn refresh(&mut self, remove_not_listed_interfaces: bool)

Refreshes the network interfaces.

use sysinfo::Networks;

let mut networks = Networks::new_with_refreshed_list();
// Wait some time...? Then refresh the data of each network.
networks.refresh(true);
Examples found in repository?
examples/simple.rs (line 87)
65fn interpret_input(
66    input: &str,
67    sys: &mut System,
68    networks: &mut Networks,
69    disks: &mut Disks,
70    components: &mut Components,
71    users: &mut Users,
72) -> bool {
73    match input.trim() {
74        "help" => print_help(),
75        "refresh_disks" => {
76            println!("Refreshing disk list...");
77            disks.refresh(true);
78            println!("Done.");
79        }
80        "refresh_users" => {
81            println!("Refreshing user list...");
82            users.refresh();
83            println!("Done.");
84        }
85        "refresh_networks" => {
86            println!("Refreshing network list...");
87            networks.refresh(true);
88            println!("Done.");
89        }
90        "refresh_components" => {
91            println!("Refreshing component list...");
92            components.refresh(true);
93            println!("Done.");
94        }
95        "refresh_cpu" => {
96            println!("Refreshing CPUs...");
97            sys.refresh_cpu_all();
98            println!("Done.");
99        }
100        "signals" => {
101            for (nb, sig) in SUPPORTED_SIGNALS.iter().enumerate() {
102                println!("{:2}:{sig:?}", nb + 1);
103            }
104        }
105        "cpus" => {
106            // Note: you should refresh a few times before using this, so that usage statistics
107            // can be ascertained
108            println!(
109                "number of physical cores: {}",
110                System::physical_core_count()
111                    .map(|c| c.to_string())
112                    .unwrap_or_else(|| "Unknown".to_owned()),
113            );
114            println!("total CPU usage: {}%", sys.global_cpu_usage(),);
115            for cpu in sys.cpus() {
116                println!("{cpu:?}");
117            }
118        }
119        "memory" => {
120            println!("total memory:     {: >10} KB", sys.total_memory() / 1_000);
121            println!(
122                "available memory: {: >10} KB",
123                sys.available_memory() / 1_000
124            );
125            println!("used memory:      {: >10} KB", sys.used_memory() / 1_000);
126            println!("total swap:       {: >10} KB", sys.total_swap() / 1_000);
127            println!("used swap:        {: >10} KB", sys.used_swap() / 1_000);
128        }
129        "quit" | "exit" => return true,
130        "all" => {
131            for (pid, proc_) in sys.processes() {
132                println!(
133                    "{}:{} status={:?}",
134                    pid,
135                    proc_.name().to_string_lossy(),
136                    proc_.status()
137                );
138            }
139        }
140        "frequency" => {
141            for cpu in sys.cpus() {
142                println!("[{}] {} MHz", cpu.name(), cpu.frequency(),);
143            }
144        }
145        "vendor_id" => {
146            println!("vendor ID: {}", sys.cpus()[0].vendor_id());
147        }
148        "brand" => {
149            println!("brand: {}", sys.cpus()[0].brand());
150        }
151        "load_avg" => {
152            let load_avg = System::load_average();
153            println!("one minute     : {}%", load_avg.one);
154            println!("five minutes   : {}%", load_avg.five);
155            println!("fifteen minutes: {}%", load_avg.fifteen);
156        }
157        e if e.starts_with("show ") => {
158            let tmp: Vec<&str> = e.split(' ').filter(|s| !s.is_empty()).collect();
159
160            if tmp.len() != 2 {
161                println!("show command takes a pid or a name in parameter!");
162                println!("example: show 1254");
163            } else if let Ok(pid) = Pid::from_str(tmp[1]) {
164                match sys.process(pid) {
165                    Some(p) => {
166                        println!("{:?}", *p);
167                        println!(
168                            "Files open/limit: {:?}/{:?}",
169                            p.open_files(),
170                            p.open_files_limit(),
171                        );
172                    }
173                    None => {
174                        println!("pid \"{pid:?}\" not found");
175                    }
176                }
177            } else {
178                let proc_name = tmp[1];
179                for proc_ in sys.processes_by_name(proc_name.as_ref()) {
180                    println!("==== {} ====", proc_.name().to_string_lossy());
181                    println!("{proc_:?}");
182                }
183            }
184        }
185        "temperature" => {
186            for component in components.iter() {
187                println!("{component:?}");
188            }
189        }
190        "network" => {
191            for (interface_name, data) in networks.iter() {
192                println!(
193                    "\
194{interface_name}:
195  ether {}
196  input data  (new / total): {} / {} B
197  output data (new / total): {} / {} B",
198                    data.mac_address(),
199                    data.received(),
200                    data.total_received(),
201                    data.transmitted(),
202                    data.total_transmitted(),
203                );
204            }
205        }
206        "show" => {
207            println!("'show' command expects a pid number or a process name");
208        }
209        e if e.starts_with("kill ") => {
210            let tmp: Vec<&str> = e
211                .split(' ')
212                .map(|s| s.trim())
213                .filter(|s| !s.is_empty())
214                .collect();
215
216            if tmp.len() != 3 {
217                println!("kill command takes the pid and a signal number in parameter!");
218                println!("example: kill 1254 9");
219            } else {
220                let Ok(pid) = Pid::from_str(tmp[1]) else {
221                    eprintln!("Expected a number for the PID, found {:?}", tmp[1]);
222                    return false;
223                };
224                let Ok(signal) = usize::from_str(tmp[2]) else {
225                    eprintln!("Expected a number for the signal, found {:?}", tmp[2]);
226                    return false;
227                };
228                let Some(signal) = SUPPORTED_SIGNALS.get(signal) else {
229                    eprintln!(
230                        "No signal matching {signal}. Use the `signals` command to get the \
231                         list of signals.",
232                    );
233                    return false;
234                };
235
236                match sys.process(pid) {
237                    Some(p) => {
238                        if let Some(res) = p.kill_with(*signal) {
239                            println!("kill: {res}");
240                        } else {
241                            eprintln!("kill: signal not supported on this platform");
242                        }
243                    }
244                    None => {
245                        eprintln!("pid not found");
246                    }
247                }
248            }
249        }
250        "disks" => {
251            for disk in disks {
252                println!("{disk:?}");
253            }
254        }
255        "users" => {
256            for user in users {
257                println!("{:?} => {:?}", user.name(), user.groups(),);
258            }
259        }
260        "groups" => {
261            for group in Groups::new_with_refreshed_list().list() {
262                println!("{group:?}");
263            }
264        }
265        "boot_time" => {
266            println!("{} seconds", System::boot_time());
267        }
268        "uptime" => {
269            let up = System::uptime();
270            let mut uptime = up;
271            let days = uptime / 86400;
272            uptime -= days * 86400;
273            let hours = uptime / 3600;
274            uptime -= hours * 3600;
275            let minutes = uptime / 60;
276            println!("{days} days {hours} hours {minutes} minutes ({up} seconds in total)",);
277        }
278        x if x.starts_with("refresh") => {
279            if x == "refresh" {
280                println!("Getting processes' information...");
281                sys.refresh_all();
282                println!("Done.");
283            } else if x.starts_with("refresh ") {
284                println!("Getting process' information...");
285                if let Some(pid) = x
286                    .split(' ')
287                    .filter_map(|pid| pid.parse().ok())
288                    .take(1)
289                    .next()
290                {
291                    if sys.refresh_processes(sysinfo::ProcessesToUpdate::Some(&[pid]), true) != 0 {
292                        println!("Process `{pid}` updated successfully");
293                    } else {
294                        println!("Process `{pid}` couldn't be updated...");
295                    }
296                } else {
297                    println!("Invalid [pid] received...");
298                }
299            } else {
300                println!(
301                    "\"{x}\": Unknown command. Enter 'help' if you want to get the commands' \
302                     list.",
303                );
304            }
305        }
306        "pid" => {
307            println!(
308                "PID: {}",
309                sysinfo::get_current_pid().expect("failed to get PID")
310            );
311        }
312        "system" => {
313            println!(
314                "System name:              {}\n\
315                 System kernel version:    {}\n\
316                 System OS version:        {}\n\
317                 System OS (long) version: {}\n\
318                 System host name:         {}\n\
319                 System kernel:            {}",
320                System::name().unwrap_or_else(|| "<unknown>".to_owned()),
321                System::kernel_version().unwrap_or_else(|| "<unknown>".to_owned()),
322                System::os_version().unwrap_or_else(|| "<unknown>".to_owned()),
323                System::long_os_version().unwrap_or_else(|| "<unknown>".to_owned()),
324                System::host_name().unwrap_or_else(|| "<unknown>".to_owned()),
325                System::kernel_long_version(),
326            );
327        }
328        e => {
329            println!(
330                "\"{e}\": Unknown command. Enter 'help' if you want to get the commands' \
331                 list.",
332            );
333        }
334    }
335    false
336}

Methods from Deref<Target = HashMap<String, NetworkData>>§

1.0.0

pub fn capacity(&self) -> usize

Returns the number of elements the map can hold without reallocating.

This number is a lower bound; the HashMap<K, V> might be able to hold more, but is guaranteed to be able to hold at least this many.

§Examples
use std::collections::HashMap;
let map: HashMap<i32, i32> = HashMap::with_capacity(100);
assert!(map.capacity() >= 100);
1.0.0

pub fn keys(&self) -> Keys<'_, K, V>

An iterator visiting all keys in arbitrary order. The iterator element type is &'a K.

§Examples
use std::collections::HashMap;

let map = HashMap::from([
    ("a", 1),
    ("b", 2),
    ("c", 3),
]);

for key in map.keys() {
    println!("{key}");
}
§Performance

In the current implementation, iterating over keys takes O(capacity) time instead of O(len) because it internally visits empty buckets too.

1.0.0

pub fn values(&self) -> Values<'_, K, V>

An iterator visiting all values in arbitrary order. The iterator element type is &'a V.

§Examples
use std::collections::HashMap;

let map = HashMap::from([
    ("a", 1),
    ("b", 2),
    ("c", 3),
]);

for val in map.values() {
    println!("{val}");
}
§Performance

In the current implementation, iterating over values takes O(capacity) time instead of O(len) because it internally visits empty buckets too.

1.0.0

pub fn iter(&self) -> Iter<'_, K, V>

An iterator visiting all key-value pairs in arbitrary order. The iterator element type is (&'a K, &'a V).

§Examples
use std::collections::HashMap;

let map = HashMap::from([
    ("a", 1),
    ("b", 2),
    ("c", 3),
]);

for (key, val) in map.iter() {
    println!("key: {key} val: {val}");
}
§Performance

In the current implementation, iterating over map takes O(capacity) time instead of O(len) because it internally visits empty buckets too.

Examples found in repository?
examples/simple.rs (line 191)
65fn interpret_input(
66    input: &str,
67    sys: &mut System,
68    networks: &mut Networks,
69    disks: &mut Disks,
70    components: &mut Components,
71    users: &mut Users,
72) -> bool {
73    match input.trim() {
74        "help" => print_help(),
75        "refresh_disks" => {
76            println!("Refreshing disk list...");
77            disks.refresh(true);
78            println!("Done.");
79        }
80        "refresh_users" => {
81            println!("Refreshing user list...");
82            users.refresh();
83            println!("Done.");
84        }
85        "refresh_networks" => {
86            println!("Refreshing network list...");
87            networks.refresh(true);
88            println!("Done.");
89        }
90        "refresh_components" => {
91            println!("Refreshing component list...");
92            components.refresh(true);
93            println!("Done.");
94        }
95        "refresh_cpu" => {
96            println!("Refreshing CPUs...");
97            sys.refresh_cpu_all();
98            println!("Done.");
99        }
100        "signals" => {
101            for (nb, sig) in SUPPORTED_SIGNALS.iter().enumerate() {
102                println!("{:2}:{sig:?}", nb + 1);
103            }
104        }
105        "cpus" => {
106            // Note: you should refresh a few times before using this, so that usage statistics
107            // can be ascertained
108            println!(
109                "number of physical cores: {}",
110                System::physical_core_count()
111                    .map(|c| c.to_string())
112                    .unwrap_or_else(|| "Unknown".to_owned()),
113            );
114            println!("total CPU usage: {}%", sys.global_cpu_usage(),);
115            for cpu in sys.cpus() {
116                println!("{cpu:?}");
117            }
118        }
119        "memory" => {
120            println!("total memory:     {: >10} KB", sys.total_memory() / 1_000);
121            println!(
122                "available memory: {: >10} KB",
123                sys.available_memory() / 1_000
124            );
125            println!("used memory:      {: >10} KB", sys.used_memory() / 1_000);
126            println!("total swap:       {: >10} KB", sys.total_swap() / 1_000);
127            println!("used swap:        {: >10} KB", sys.used_swap() / 1_000);
128        }
129        "quit" | "exit" => return true,
130        "all" => {
131            for (pid, proc_) in sys.processes() {
132                println!(
133                    "{}:{} status={:?}",
134                    pid,
135                    proc_.name().to_string_lossy(),
136                    proc_.status()
137                );
138            }
139        }
140        "frequency" => {
141            for cpu in sys.cpus() {
142                println!("[{}] {} MHz", cpu.name(), cpu.frequency(),);
143            }
144        }
145        "vendor_id" => {
146            println!("vendor ID: {}", sys.cpus()[0].vendor_id());
147        }
148        "brand" => {
149            println!("brand: {}", sys.cpus()[0].brand());
150        }
151        "load_avg" => {
152            let load_avg = System::load_average();
153            println!("one minute     : {}%", load_avg.one);
154            println!("five minutes   : {}%", load_avg.five);
155            println!("fifteen minutes: {}%", load_avg.fifteen);
156        }
157        e if e.starts_with("show ") => {
158            let tmp: Vec<&str> = e.split(' ').filter(|s| !s.is_empty()).collect();
159
160            if tmp.len() != 2 {
161                println!("show command takes a pid or a name in parameter!");
162                println!("example: show 1254");
163            } else if let Ok(pid) = Pid::from_str(tmp[1]) {
164                match sys.process(pid) {
165                    Some(p) => {
166                        println!("{:?}", *p);
167                        println!(
168                            "Files open/limit: {:?}/{:?}",
169                            p.open_files(),
170                            p.open_files_limit(),
171                        );
172                    }
173                    None => {
174                        println!("pid \"{pid:?}\" not found");
175                    }
176                }
177            } else {
178                let proc_name = tmp[1];
179                for proc_ in sys.processes_by_name(proc_name.as_ref()) {
180                    println!("==== {} ====", proc_.name().to_string_lossy());
181                    println!("{proc_:?}");
182                }
183            }
184        }
185        "temperature" => {
186            for component in components.iter() {
187                println!("{component:?}");
188            }
189        }
190        "network" => {
191            for (interface_name, data) in networks.iter() {
192                println!(
193                    "\
194{interface_name}:
195  ether {}
196  input data  (new / total): {} / {} B
197  output data (new / total): {} / {} B",
198                    data.mac_address(),
199                    data.received(),
200                    data.total_received(),
201                    data.transmitted(),
202                    data.total_transmitted(),
203                );
204            }
205        }
206        "show" => {
207            println!("'show' command expects a pid number or a process name");
208        }
209        e if e.starts_with("kill ") => {
210            let tmp: Vec<&str> = e
211                .split(' ')
212                .map(|s| s.trim())
213                .filter(|s| !s.is_empty())
214                .collect();
215
216            if tmp.len() != 3 {
217                println!("kill command takes the pid and a signal number in parameter!");
218                println!("example: kill 1254 9");
219            } else {
220                let Ok(pid) = Pid::from_str(tmp[1]) else {
221                    eprintln!("Expected a number for the PID, found {:?}", tmp[1]);
222                    return false;
223                };
224                let Ok(signal) = usize::from_str(tmp[2]) else {
225                    eprintln!("Expected a number for the signal, found {:?}", tmp[2]);
226                    return false;
227                };
228                let Some(signal) = SUPPORTED_SIGNALS.get(signal) else {
229                    eprintln!(
230                        "No signal matching {signal}. Use the `signals` command to get the \
231                         list of signals.",
232                    );
233                    return false;
234                };
235
236                match sys.process(pid) {
237                    Some(p) => {
238                        if let Some(res) = p.kill_with(*signal) {
239                            println!("kill: {res}");
240                        } else {
241                            eprintln!("kill: signal not supported on this platform");
242                        }
243                    }
244                    None => {
245                        eprintln!("pid not found");
246                    }
247                }
248            }
249        }
250        "disks" => {
251            for disk in disks {
252                println!("{disk:?}");
253            }
254        }
255        "users" => {
256            for user in users {
257                println!("{:?} => {:?}", user.name(), user.groups(),);
258            }
259        }
260        "groups" => {
261            for group in Groups::new_with_refreshed_list().list() {
262                println!("{group:?}");
263            }
264        }
265        "boot_time" => {
266            println!("{} seconds", System::boot_time());
267        }
268        "uptime" => {
269            let up = System::uptime();
270            let mut uptime = up;
271            let days = uptime / 86400;
272            uptime -= days * 86400;
273            let hours = uptime / 3600;
274            uptime -= hours * 3600;
275            let minutes = uptime / 60;
276            println!("{days} days {hours} hours {minutes} minutes ({up} seconds in total)",);
277        }
278        x if x.starts_with("refresh") => {
279            if x == "refresh" {
280                println!("Getting processes' information...");
281                sys.refresh_all();
282                println!("Done.");
283            } else if x.starts_with("refresh ") {
284                println!("Getting process' information...");
285                if let Some(pid) = x
286                    .split(' ')
287                    .filter_map(|pid| pid.parse().ok())
288                    .take(1)
289                    .next()
290                {
291                    if sys.refresh_processes(sysinfo::ProcessesToUpdate::Some(&[pid]), true) != 0 {
292                        println!("Process `{pid}` updated successfully");
293                    } else {
294                        println!("Process `{pid}` couldn't be updated...");
295                    }
296                } else {
297                    println!("Invalid [pid] received...");
298                }
299            } else {
300                println!(
301                    "\"{x}\": Unknown command. Enter 'help' if you want to get the commands' \
302                     list.",
303                );
304            }
305        }
306        "pid" => {
307            println!(
308                "PID: {}",
309                sysinfo::get_current_pid().expect("failed to get PID")
310            );
311        }
312        "system" => {
313            println!(
314                "System name:              {}\n\
315                 System kernel version:    {}\n\
316                 System OS version:        {}\n\
317                 System OS (long) version: {}\n\
318                 System host name:         {}\n\
319                 System kernel:            {}",
320                System::name().unwrap_or_else(|| "<unknown>".to_owned()),
321                System::kernel_version().unwrap_or_else(|| "<unknown>".to_owned()),
322                System::os_version().unwrap_or_else(|| "<unknown>".to_owned()),
323                System::long_os_version().unwrap_or_else(|| "<unknown>".to_owned()),
324                System::host_name().unwrap_or_else(|| "<unknown>".to_owned()),
325                System::kernel_long_version(),
326            );
327        }
328        e => {
329            println!(
330                "\"{e}\": Unknown command. Enter 'help' if you want to get the commands' \
331                 list.",
332            );
333        }
334    }
335    false
336}
1.0.0

pub fn len(&self) -> usize

Returns the number of elements in the map.

§Examples
use std::collections::HashMap;

let mut a = HashMap::new();
assert_eq!(a.len(), 0);
a.insert(1, "a");
assert_eq!(a.len(), 1);
1.0.0

pub fn is_empty(&self) -> bool

Returns true if the map contains no elements.

§Examples
use std::collections::HashMap;

let mut a = HashMap::new();
assert!(a.is_empty());
a.insert(1, "a");
assert!(!a.is_empty());
1.9.0

pub fn hasher(&self) -> &S

Returns a reference to the map’s [BuildHasher].

§Examples
use std::collections::HashMap;
use std::hash::RandomState;

let hasher = RandomState::new();
let map: HashMap<i32, i32> = HashMap::with_hasher(hasher);
let hasher: &RandomState = map.hasher();
1.0.0

pub fn get<Q>(&self, k: &Q) -> Option<&V>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Returns a reference to the value corresponding to the key.

The key may be any borrowed form of the map’s key type, but [Hash] and [Eq] on the borrowed form must match those for the key type.

§Examples
use std::collections::HashMap;

let mut map = HashMap::new();
map.insert(1, "a");
assert_eq!(map.get(&1), Some(&"a"));
assert_eq!(map.get(&2), None);
1.40.0

pub fn get_key_value<Q>(&self, k: &Q) -> Option<(&K, &V)>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Returns the key-value pair corresponding to the supplied key. This is potentially useful:

  • for key types where non-identical keys can be considered equal;
  • for getting the &K stored key value from a borrowed &Q lookup key; or
  • for getting a reference to a key with the same lifetime as the collection.

The supplied key may be any borrowed form of the map’s key type, but [Hash] and [Eq] on the borrowed form must match those for the key type.

§Examples
use std::collections::HashMap;
use std::hash::{Hash, Hasher};

#[derive(Clone, Copy, Debug)]
struct S {
    id: u32,
    name: &'static str, // ignored by equality and hashing operations
}

impl PartialEq for S {
    fn eq(&self, other: &S) -> bool {
        self.id == other.id
    }
}

impl Eq for S {}

impl Hash for S {
    fn hash<H: Hasher>(&self, state: &mut H) {
        self.id.hash(state);
    }
}

let j_a = S { id: 1, name: "Jessica" };
let j_b = S { id: 1, name: "Jess" };
let p = S { id: 2, name: "Paul" };
assert_eq!(j_a, j_b);

let mut map = HashMap::new();
map.insert(j_a, "Paris");
assert_eq!(map.get_key_value(&j_a), Some((&j_a, &"Paris")));
assert_eq!(map.get_key_value(&j_b), Some((&j_a, &"Paris"))); // the notable case
assert_eq!(map.get_key_value(&p), None);
1.0.0

pub fn contains_key<Q>(&self, k: &Q) -> bool
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Returns true if the map contains a value for the specified key.

The key may be any borrowed form of the map’s key type, but [Hash] and [Eq] on the borrowed form must match those for the key type.

§Examples
use std::collections::HashMap;

let mut map = HashMap::new();
map.insert(1, "a");
assert_eq!(map.contains_key(&1), true);
assert_eq!(map.contains_key(&2), false);

Trait Implementations§

Source§

impl Debug for Networks

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Networks

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Deref for Networks

Source§

type Target = HashMap<String, NetworkData>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'a> IntoIterator for &'a Networks

Source§

type Item = (&'a String, &'a NetworkData)

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, String, NetworkData>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl Serialize for Networks

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Networks

§

impl RefUnwindSafe for Networks

§

impl Send for Networks

§

impl Sync for Networks

§

impl Unpin for Networks

§

impl UnwindSafe for Networks

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.