pub struct SCNetworkReachability(/* private fields */);
Expand description
A network address or host for which the connectivity can be determined.
See SCNetworkReachability
for details.
Implementations§
Source§impl SCNetworkReachability
impl SCNetworkReachability
Sourcepub fn from_addr_pair(
local: SocketAddr,
remote: SocketAddr,
) -> SCNetworkReachability
pub fn from_addr_pair( local: SocketAddr, remote: SocketAddr, ) -> SCNetworkReachability
Construct a SCNetworkReachability struct with a local and a remote socket address.
See SCNetworkReachabilityCreateWithAddressPair
for details.
Sourcepub fn from_host(host: &CStr) -> Option<Self>
pub fn from_host(host: &CStr) -> Option<Self>
Construct a Reachability from either a hostname or a network node
See SCNetworkReachabilityCreateWithName
for details.
Sourcepub fn reachability(&self) -> Result<ReachabilityFlags, ReachabilityError>
pub fn reachability(&self) -> Result<ReachabilityFlags, ReachabilityError>
Return a flag indicating whether the specified network address is reachable.
See SCNetworkReachabilityGetFlags
for details.
Sourcepub unsafe fn schedule_with_runloop(
&self,
run_loop: &CFRunLoop,
run_loop_mode: CFStringRef,
) -> Result<(), SchedulingError>
pub unsafe fn schedule_with_runloop( &self, run_loop: &CFRunLoop, run_loop_mode: CFStringRef, ) -> Result<(), SchedulingError>
Schedule callback with runloop.
See SCNetworkReachabilityScheduleFromRunLoop
for details.
§Safety
The run_loop_mode
must not be NULL and must be a pointer to a valid run loop mode.
Use core_foundation::runloop::kCFRunLoopCommonModes
if you are unsure.
Sourcepub unsafe fn unschedule_from_runloop(
&self,
run_loop: &CFRunLoop,
run_loop_mode: CFStringRef,
) -> Result<(), UnschedulingError>
pub unsafe fn unschedule_from_runloop( &self, run_loop: &CFRunLoop, run_loop_mode: CFStringRef, ) -> Result<(), UnschedulingError>
Unschedule from run loop.
See SCNetworkReachabilityUnscheduleFromRunLoop
for details.
§Safety
The run_loop_mode
must not be NULL and must be a pointer to a valid run loop mode.
Use core_foundation::runloop::kCFRunLoopCommonModes
if you are unsure.
Sourcepub fn set_callback<F: Fn(ReachabilityFlags) + Sync + Send>(
&mut self,
callback: F,
) -> Result<(), SetCallbackError>
pub fn set_callback<F: Fn(ReachabilityFlags) + Sync + Send>( &mut self, callback: F, ) -> Result<(), SetCallbackError>
Sets callback that is run whenever network connectivity changes. For the callback to be
invoked, the SCNetworkReachability
has to be registered on a run loop. Calling this
function multiple times will clear the subsequently set callback.
See SCNetworkReachabilityContext
for details.
Trait Implementations§
Source§impl Clone for SCNetworkReachability
impl Clone for SCNetworkReachability
Source§fn clone(&self) -> SCNetworkReachability
fn clone(&self) -> SCNetworkReachability
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Drop for SCNetworkReachability
impl Drop for SCNetworkReachability
Source§impl From<SocketAddr> for SCNetworkReachability
impl From<SocketAddr> for SCNetworkReachability
Source§fn from(addr: SocketAddr) -> Self
fn from(addr: SocketAddr) -> Self
Source§impl PartialEq for SCNetworkReachability
impl PartialEq for SCNetworkReachability
Source§impl TCFType for SCNetworkReachability
impl TCFType for SCNetworkReachability
Source§fn as_concrete_TypeRef(&self) -> SCNetworkReachabilityRef
fn as_concrete_TypeRef(&self) -> SCNetworkReachabilityRef
TypeRef
.Source§unsafe fn wrap_under_get_rule(reference: SCNetworkReachabilityRef) -> Self
unsafe fn wrap_under_get_rule(reference: SCNetworkReachabilityRef) -> Self
CFTypeRef
subclass. Use this
when following Core Foundation’s “Get Rule”. The reference count is bumped.Source§fn as_CFTypeRef(&self) -> CFTypeRef
fn as_CFTypeRef(&self) -> CFTypeRef
CFTypeRef
. The reference count is not adjusted.Source§unsafe fn wrap_under_create_rule(reference: SCNetworkReachabilityRef) -> Self
unsafe fn wrap_under_create_rule(reference: SCNetworkReachabilityRef) -> Self
CFTypeRef
subclass. Use this
when following Core Foundation’s “Create Rule”. The reference count is not bumped.Source§fn as_CFType(&self) -> CFType
fn as_CFType(&self) -> CFType
CFType
. The reference count is incremented by one.Source§fn into_CFType(self) -> CFTypewhere
Self: Sized,
fn into_CFType(self) -> CFTypewhere
Self: Sized,
CFType
. Consumes self and avoids changing the reference
count.Source§fn retain_count(&self) -> isize
fn retain_count(&self) -> isize
Source§fn instance_of<OtherCFType>(&self) -> boolwhere
OtherCFType: TCFType,
fn instance_of<OtherCFType>(&self) -> boolwhere
OtherCFType: TCFType,
true
if this value is an instance of another type.