Skip to content

Commit b02a297

Browse files
author
luozijun
committed
code fmt
1 parent 56009cb commit b02a297

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

system-configuration/examples/network_configuration.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
extern crate system_configuration;
22

3-
use system_configuration::network_configuration::{global_router, SCNetworkService, SCNetworkInterface};
4-
use system_configuration::dynamic_store::{SCDynamicStoreBuilder};
3+
use system_configuration::dynamic_store::SCDynamicStoreBuilder;
4+
use system_configuration::network_configuration::{global_router, SCNetworkInterface,
5+
SCNetworkService};
56

67
// This example will output network-global-service, network-global-interface, network-global-router,
78
// network-service-order-list, network-services and network-interfaces to stdout.
89

910
fn main() {
1011
let store = SCDynamicStoreBuilder::new("session_name").build();
11-
12+
1213

1314
println!("Global Service:\n{:?}\n", SCNetworkService::global(&store));
14-
println!("Global Interface:\n{:?}\n", SCNetworkInterface::global(&store));
15+
println!(
16+
"Global Interface:\n{:?}\n",
17+
SCNetworkInterface::global(&store)
18+
);
1519
println!("Global Service Router:\n{:?}\n", global_router(&store));
1620

1721
println!("\n-listnetworkserviceorder:");

system-configuration/src/network_configuration.rs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use core_foundation::base::kCFAllocatorDefault;
1818
use core_foundation::dictionary::CFDictionary;
1919
use core_foundation::string::{CFString, CFStringRef};
2020

21-
use dynamic_store::{SCDynamicStoreBuilder, SCDynamicStore};
21+
use dynamic_store::{SCDynamicStore, SCDynamicStoreBuilder};
2222
pub use system_configuration_sys::network_configuration::*;
2323
use system_configuration_sys::preferences::SCPreferencesCreate;
2424

@@ -60,7 +60,7 @@ impl SCNetworkServiceDns {
6060
setup_server_addresses: server_addresses.1,
6161
}
6262
}
63-
63+
6464
/// Returns DomainName (state and setup)
6565
pub fn domain_name(&self) -> (Option<String>, Option<String>) {
6666
(
@@ -108,17 +108,17 @@ pub fn global_router(store: &SCDynamicStore) -> Option<IpAddr> {
108108
return None;
109109
}
110110

111-
// pub fn netinfo(&self);
112-
// pub fn proxies(&self) ;
113-
114111

115112
declare_TCFType!{
116113
/// Network service object.
117114
SCNetworkService, SCNetworkServiceRef
118115
}
119116

120-
impl_TCFType!(SCNetworkService, SCNetworkServiceRef, SCNetworkServiceGetTypeID);
121-
117+
impl_TCFType!(
118+
SCNetworkService,
119+
SCNetworkServiceRef,
120+
SCNetworkServiceGetTypeID
121+
);
122122

123123

124124
impl SCNetworkService {
@@ -152,11 +152,7 @@ impl SCNetworkService {
152152
array
153153
.get_all_values()
154154
.iter()
155-
.map(|service_ptr| {
156-
unsafe {
157-
SCNetworkService::wrap_under_get_rule(*service_ptr as _)
158-
}
159-
})
155+
.map(|service_ptr| unsafe { SCNetworkService::wrap_under_get_rule(*service_ptr as _) })
160156
.collect::<Vec<SCNetworkService>>()
161157
}
162158

@@ -178,7 +174,8 @@ impl SCNetworkService {
178174
let mut services = Vec::new();
179175

180176
for id_ptr in array.get_all_values().iter() {
181-
let service_ptr: SCNetworkServiceRef = unsafe { SCNetworkServiceCopy(prefs, *id_ptr as _) };
177+
let service_ptr: SCNetworkServiceRef =
178+
unsafe { SCNetworkServiceCopy(prefs, *id_ptr as _) };
182179
services.push(unsafe { SCNetworkService::wrap_under_get_rule(service_ptr) });
183180
}
184181

@@ -330,7 +327,11 @@ declare_TCFType!{
330327
SCNetworkInterface, SCNetworkInterfaceRef
331328
}
332329

333-
impl_TCFType!(SCNetworkInterface, SCNetworkInterfaceRef, SCNetworkInterfaceGetTypeID);
330+
impl_TCFType!(
331+
SCNetworkInterface,
332+
SCNetworkInterfaceRef,
333+
SCNetworkInterfaceGetTypeID
334+
);
334335

335336

336337
impl SCNetworkInterface {
@@ -357,10 +358,8 @@ impl SCNetworkInterface {
357358
array
358359
.get_all_values()
359360
.iter()
360-
.map(|interface_ptr| {
361-
unsafe {
362-
SCNetworkInterface::wrap_under_get_rule(*interface_ptr as _)
363-
}
361+
.map(|interface_ptr| unsafe {
362+
SCNetworkInterface::wrap_under_get_rule(*interface_ptr as _)
364363
})
365364
.collect::<Vec<SCNetworkInterface>>()
366365
}

0 commit comments

Comments
 (0)