Skip to main content

sl4f_lib/wlan/
commands.rs

1// Copyright 2021 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use crate::server::Facade;
6use anyhow::{Error, format_err};
7use async_trait::async_trait;
8use log::*;
9use serde_json::{Value, to_value};
10
11// Testing helper methods
12use crate::wlan::facade::WlanFacade;
13
14#[async_trait(?Send)]
15impl Facade for WlanFacade {
16    async fn handle_request(&self, method: String, _args: Value) -> Result<Value, Error> {
17        match method.as_ref() {
18            "status" => {
19                info!(tag = "WlanFacade"; "fetching connection status");
20                let result = self.status().await?;
21                to_value(result).map_err(|e| format_err!("error handling connection status: {}", e))
22            }
23            _ => return Err(format_err!("unsupported command!")),
24        }
25    }
26}