pub trait NetworkEventProcessor: Send + Sync {
// Required methods
fn process_network_available<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn process_network_lost<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn process_network_type_changed<'life0, 'async_trait>(
&'life0 self,
is_wifi: bool,
is_cellular: bool,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn cleanup_connections<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn process_network_recovery_action<'life0, 'async_trait>(
&'life0 self,
action: NetworkRecoveryAction,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Network event processor trait
Defines the processing logic for network events; can be custom-implemented by users
Required Methods§
Sourcefn process_network_available<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn process_network_available<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Process network available event
§Returns
Ok(()): processing succeededErr(String): processing failed, contains error message
Sourcefn process_network_lost<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn process_network_lost<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Process network lost event
§Returns
Ok(()): processing succeededErr(String): processing failed, contains error message
Sourcefn process_network_type_changed<'life0, 'async_trait>(
&'life0 self,
is_wifi: bool,
is_cellular: bool,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn process_network_type_changed<'life0, 'async_trait>(
&'life0 self,
is_wifi: bool,
is_cellular: bool,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Process network type changed event
§Returns
Ok(()): processing succeededErr(String): processing failed, contains error message
Sourcefn cleanup_connections<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn cleanup_connections<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Proactively clean up all connections
This method proactively cleans up all network connections. Applicable scenarios:
- App entering background (iOS/Android)
- User actively logging out
- App about to exit
- Need to reset network state
§FFI Binding Note
This method is specifically designed for FFI bindings, allowing upper-layer
platform code (Swift/Kotlin) to proactively manage connection lifecycle
through the unified NetworkEventProcessor interface.
§Difference from Event Response
process_network_lost(): passively responds to network disconnection eventscleanup_connections(): proactively cleans up connections (independent of network events)
§Returns
Ok(()): cleanup succeededErr(String): cleanup failed, contains error message
Provided Methods§
Sourcefn process_network_recovery_action<'life0, 'async_trait>(
&'life0 self,
action: NetworkRecoveryAction,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn process_network_recovery_action<'life0, 'async_trait>(
&'life0 self,
action: NetworkRecoveryAction,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Process the final action selected from a settled event batch.
Custom processors can rely on the default mapping. The default runtime processor overrides this to bypass per-event debounce after reconciliation.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".