Skip to main content

Network

Trait Network 

Source
pub trait Network:
    Send
    + Sync
    + 'static {
    // Provided methods
    fn get_network_info(&self, callback_id: u64) -> Result<(), PlatformError> { ... }
    fn add_network_change_listener(
        &self,
        callback_id: u64,
    ) -> Result<(), PlatformError> { ... }
    fn remove_network_change_listener(
        &self,
        callback_id: u64,
    ) -> Result<(), PlatformError> { ... }
}

Provided Methods§

Source

fn get_network_info(&self, callback_id: u64) -> Result<(), PlatformError>

Get current network info via callback.

Callback payload example: { "isConnected": true, "networkType": "wifi", "ipv4": ["192.168.1.12"], "ipv6": ["240e:3a1:..."] }

Source

fn add_network_change_listener( &self, callback_id: u64, ) -> Result<(), PlatformError>

Add listener for network changes.

Platform should push callback payload: { "isConnected": boolean, "networkType": "none|unknown|wifi|2g|3g|4g|5g|ethernet", "ipv4": string[], "ipv6": string[] }

Source

fn remove_network_change_listener( &self, callback_id: u64, ) -> Result<(), PlatformError>

Remove a previously registered network change listener.

Implementors§