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.source§impl<'a> ToVoid<SCNetworkReachability> for &'a SCNetworkReachability
impl<'a> ToVoid<SCNetworkReachability> for &'a SCNetworkReachability
impl ConcreteCFType for SCNetworkReachability
impl Eq for SCNetworkReachability
Auto Trait Implementations§
impl Freeze for SCNetworkReachability
impl RefUnwindSafe for SCNetworkReachability
impl !Send for SCNetworkReachability
impl !Sync for SCNetworkReachability
impl Unpin for SCNetworkReachability
impl UnwindSafe for SCNetworkReachability
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)