pub async fn update_network(http_state: HttpServerStateSync, event: WifiConnectionEvent) {
    let mut state = http_state.lock().expect("Mutex lock for http state on update_network");
    info!("Add network {}", &event.access_point.ssid);
    let ref mut connections = state.connections.0;
    match connections.iter().position(|n| n.ssid == event.access_point.ssid) {
        Some(pos) => {
            match event.event {
                WifiConnectionEventType::Added => {
                    use std::mem;
                    let dest = connections
                        .get_mut(pos)
                        .expect("update_network: Vector access on connections");
                    mem::replace(dest, event.access_point.clone());
                },
                WifiConnectionEventType::Removed => {
                    connections.remove(pos);
                },
            };
        },
        None => {
            state.connections.0.push(event.access_point.clone());
        },
    };
    sse::send_wifi_connection(&mut state.sse, &event).expect("json encoding failed");
}
/// Call this method to update, add, remove a network
Call this method to update, add, remove a network
Call this method to update add remove a network
pub async fn update_network(http_state: HttpServerStateSync, event: WifiConnectionEvent) {
    let mut state = http_state.lock().expect("Mutex lock for http state on update_network");
    info!("Add network {}", &event.access_point.ssid);
    let ref mut connections = state.connections.0;
    match connections.iter().position(|n| n.ssid == event.access_point.ssid) {
        Some(pos) => {
            match event.event {
                WifiConnectionEventType::Added => {
                    use std::mem;
                    let dest = connections
                        .get_mut(pos)
                        .expect("update_network: Vector access on connections");
                    mem::replace(dest, event.access_point.clone());
                },
                WifiConnectionEventType::Removed => {
                    connections.remove(pos);
                },
            };
        },
        None => {
            state.connections.0.push(event.access_point.clone());
        },
    };
    sse::send_wifi_connection(&mut state.sse, &event).expect("json encoding failed");
}
pub async fn update_network ( http_state : HttpServerStateSync , event : WifiConnectionEvent ) { let mut state = http_state . lock ( ) . expect ( " " ) ; info ! ( " " event access_point ssid ) ; let ref mut connections = state . connections . 0 ; match connections . iter ( ) . position ( | n | n . ssid == event . access_point . ssid ) { Some ( pos ) => { match event . event { WifiConnectionEventType :: Added => { use std :: mem ; let dest = connections . get_mut ( pos ) . expect ( " " ) ; mem :: replace ( dest , event . access_point . clone ( ) ) ; } , WifiConnectionEventType :: Removed => { connections . remove ( pos ) ; } , } ; } , None => { state . connections . 0 . push ( event . access_point . clone ( ) ) ; } , } ; sse :: send_wifi_connection ( & mut state . sse , & event ) . expect ( " " ) ; }
Call this method to update, add, remove a network
Call this method to update add remove a network
http_state
HttpServerStateSync
event
WifiConnectionEvent
http_state
HttpServerStateSync
event
WifiConnectionEvent