wasefire_board_api/
usb.rs

1// Copyright 2022 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! USB interface.
16
17#[cfg(feature = "api-usb-serial")]
18pub mod serial;
19
20/// USB event.
21#[cfg_attr(feature = "defmt", derive(defmt::Format))]
22#[derive(Debug, PartialEq, Eq)]
23pub enum Event {
24    /// Serial event.
25    #[cfg(feature = "api-usb-serial")]
26    Serial(serial::Event),
27}
28
29impl<B: crate::Api> From<Event> for crate::Event<B> {
30    fn from(event: Event) -> Self {
31        crate::Event::Usb(event)
32    }
33}
34
35/// USB interface.
36pub trait Api: Send {
37    /// USB serial interface.
38    #[cfg(feature = "api-usb-serial")]
39    type Serial: serial::Api;
40}
41
42/// USB serial interface.
43#[cfg(feature = "api-usb-serial")]
44pub type Serial<B> = <super::Usb<B> as Api>::Serial;