wincwifi/socket.rs
1// Copyright 2023 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#[cfg_attr(feature = "defmt", derive(defmt::Format))]
16#[derive(PartialEq, Debug, Clone, Copy)]
17pub struct Socket {
18 pub v: u8, // todo make this not public
19 pub s: u16,
20}
21impl Socket {
22 pub fn new(v: u8, s: u16) -> Self {
23 Socket { v, s }
24 }
25}
26impl From<(u8, u16)> for Socket {
27 fn from(val: (u8, u16)) -> Self {
28 Socket { v: val.0, s: val.1 }
29 }
30}
31impl From<Socket> for (u8, u16) {
32 fn from(sock: Socket) -> Self {
33 (sock.v, sock.s)
34 }
35}