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.
45//! Crate wlan-common hosts common libraries
6//! to be used for WLAN SME, MLME, and binaries written in Rust.
78#![cfg_attr(feature = "benchmark", feature(test))]
9pub mod append;
10pub mod big_endian;
11pub mod bss;
12pub mod buffer_reader;
13pub mod buffer_writer;
14pub mod capabilities;
15pub mod channel;
16pub mod data_writer;
17pub mod energy;
18pub mod error;
19pub mod ie;
20pub mod mac;
21pub mod mgmt_writer;
22pub mod organization;
23pub mod scan;
24pub mod security;
25pub mod sequence;
26pub mod sequestered;
27pub mod sink;
28pub mod stats;
29#[cfg(target_os = "fuchsia")]
30pub mod test_utils;
31pub mod tim;
32pub mod time;
33#[cfg(target_os = "fuchsia")]
34pub mod timer;
35pub mod tx_vector;
36pub mod wmm;
3738use channel::{Cbw, Channel};
39use zerocopy::{Ref, Unalign};
40use {fidl_fuchsia_wlan_common as fidl_common, fidl_fuchsia_wlan_sme as fidl_sme};
4142pub use time::TimeUnit;
4344#[derive(Clone, Debug, PartialEq)]
45pub struct RadioConfig {
46pub phy: fidl_common::WlanPhyType,
47pub channel: Channel,
48}
4950impl From<RadioConfig> for fidl_sme::RadioConfig {
51fn from(radio_cfg: RadioConfig) -> fidl_sme::RadioConfig {
52 fidl_sme::RadioConfig { phy: radio_cfg.phy, channel: radio_cfg.channel.into() }
53 }
54}
5556impl TryFrom<fidl_sme::RadioConfig> for RadioConfig {
57type Error = anyhow::Error;
58fn try_from(fidl_radio_cfg: fidl_sme::RadioConfig) -> Result<RadioConfig, Self::Error> {
59Ok(RadioConfig { phy: fidl_radio_cfg.phy, channel: fidl_radio_cfg.channel.try_into()? })
60 }
61}
6263impl RadioConfig {
64pub fn new(phy: fidl_common::WlanPhyType, cbw: Cbw, primary_channel: u8) -> Self {
65 RadioConfig { phy, channel: Channel::new(primary_channel, cbw) }
66 }
67}
6869pub type UnalignedView<B, T> = Ref<B, Unalign<T>>;