Skip to content

Commit 2ae093d

Browse files
ryan-summerseldruin
authored andcommitted
Formatting
1 parent 5cf4c96 commit 2ae093d

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

src/stack/share.rs

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -63,28 +63,28 @@ use core::cell::RefCell;
6363
/// # Ok::<(), ()>(())
6464
/// ```
6565
pub struct SharableStack<T> {
66-
stack: RefCell<T>,
66+
stack: RefCell<T>,
6767
}
6868

6969
impl<T> SharableStack<T> {
70-
/// Create a new SharedStack that contains and uses some other stack implementation.
71-
pub fn new(stack: T) -> Self {
72-
SharableStack {
73-
stack: RefCell::new(stack),
74-
}
75-
}
70+
/// Create a new SharedStack that contains and uses some other stack implementation.
71+
pub fn new(stack: T) -> Self {
72+
SharableStack {
73+
stack: RefCell::new(stack),
74+
}
75+
}
7676

77-
/// Returns a shared reference to the driver that can be used as a first-class implementation.
78-
pub fn acquire(&self) -> SharedStack<T> {
79-
SharedStack { stack: &self.stack }
80-
}
77+
/// Returns a shared reference to the driver that can be used as a first-class implementation.
78+
pub fn acquire(&self) -> SharedStack<T> {
79+
SharedStack { stack: &self.stack }
80+
}
8181
}
8282

8383
/// Single-thread shared reference to an internal network stack implementation.
8484
///
8585
/// This can only be created by calling [`SharableStack::acquire()`]
8686
pub struct SharedStack<'a, T> {
87-
stack: &'a RefCell<T>,
87+
stack: &'a RefCell<T>,
8888
}
8989

9090
macro_rules! forward {
@@ -97,46 +97,46 @@ macro_rules! forward {
9797

9898
impl<'a, T> UdpClientStack for SharedStack<'a, T>
9999
where
100-
T: UdpClientStack,
100+
T: UdpClientStack,
101101
{
102-
type Error = T::Error;
103-
type UdpSocket = T::UdpSocket;
102+
type Error = T::Error;
103+
type UdpSocket = T::UdpSocket;
104104

105-
forward! {socket() -> Result<Self::UdpSocket, Self::Error>}
106-
forward! {connect(socket: &mut Self::UdpSocket, address: SocketAddr) -> Result<(), Self::Error>}
107-
forward! {send(socket: &mut Self::UdpSocket, data: &[u8]) -> Result<(), nb::Error<<T as UdpClientStack>::Error>>}
108-
forward! {receive(socket: &mut Self::UdpSocket, data: &mut [u8]) -> Result<(usize, SocketAddr), nb::Error<<T as UdpClientStack>::Error>>}
109-
forward! {close(socket: Self::UdpSocket) -> Result<(), Self::Error>}
105+
forward! {socket() -> Result<Self::UdpSocket, Self::Error>}
106+
forward! {connect(socket: &mut Self::UdpSocket, address: SocketAddr) -> Result<(), Self::Error>}
107+
forward! {send(socket: &mut Self::UdpSocket, data: &[u8]) -> Result<(), nb::Error<<T as UdpClientStack>::Error>>}
108+
forward! {receive(socket: &mut Self::UdpSocket, data: &mut [u8]) -> Result<(usize, SocketAddr), nb::Error<<T as UdpClientStack>::Error>>}
109+
forward! {close(socket: Self::UdpSocket) -> Result<(), Self::Error>}
110110
}
111111

112112
impl<'a, T> UdpFullStack for SharedStack<'a, T>
113113
where
114-
T: UdpFullStack,
114+
T: UdpFullStack,
115115
{
116-
forward! {bind(socket: &mut Self::UdpSocket, local_port: u16) -> Result<(), Self::Error>}
117-
forward! {send_to(socket: &mut Self::UdpSocket, remote: SocketAddr, buffer: &[u8]) -> Result<(), nb::Error<<T as UdpClientStack>::Error>>}
116+
forward! {bind(socket: &mut Self::UdpSocket, local_port: u16) -> Result<(), Self::Error>}
117+
forward! {send_to(socket: &mut Self::UdpSocket, remote: SocketAddr, buffer: &[u8]) -> Result<(), nb::Error<<T as UdpClientStack>::Error>>}
118118
}
119119

120120
impl<'a, T> TcpClientStack for SharedStack<'a, T>
121121
where
122-
T: TcpClientStack,
122+
T: TcpClientStack,
123123
{
124-
type TcpSocket = T::TcpSocket;
125-
type Error = T::Error;
124+
type TcpSocket = T::TcpSocket;
125+
type Error = T::Error;
126126

127-
forward! {socket() -> Result<Self::TcpSocket, Self::Error>}
128-
forward! {connect(socket: &mut Self::TcpSocket, address: SocketAddr) -> Result<(), nb::Error<<T as TcpClientStack>::Error>>}
129-
forward! {send(socket: &mut Self::TcpSocket, data: &[u8]) -> Result<usize, nb::Error<<T as TcpClientStack>::Error>>}
130-
forward! {receive(socket: &mut Self::TcpSocket, data: &mut [u8]) -> Result<usize, nb::Error<<T as TcpClientStack>::Error>>}
131-
forward! {is_connected(socket: &Self::TcpSocket) -> Result<bool, Self::Error>}
132-
forward! {close(socket: Self::TcpSocket) -> Result<(), Self::Error>}
127+
forward! {socket() -> Result<Self::TcpSocket, Self::Error>}
128+
forward! {connect(socket: &mut Self::TcpSocket, address: SocketAddr) -> Result<(), nb::Error<<T as TcpClientStack>::Error>>}
129+
forward! {send(socket: &mut Self::TcpSocket, data: &[u8]) -> Result<usize, nb::Error<<T as TcpClientStack>::Error>>}
130+
forward! {receive(socket: &mut Self::TcpSocket, data: &mut [u8]) -> Result<usize, nb::Error<<T as TcpClientStack>::Error>>}
131+
forward! {is_connected(socket: &Self::TcpSocket) -> Result<bool, Self::Error>}
132+
forward! {close(socket: Self::TcpSocket) -> Result<(), Self::Error>}
133133
}
134134

135135
impl<'a, T> TcpFullStack for SharedStack<'a, T>
136136
where
137-
T: TcpFullStack,
137+
T: TcpFullStack,
138138
{
139-
forward! {bind(socket: &mut Self::TcpSocket, port: u16) -> Result<(), <T as TcpClientStack>::Error>}
140-
forward! {listen(socket: &mut Self::TcpSocket) -> Result<(), <T as TcpClientStack>::Error>}
141-
forward! {accept(socket: &mut Self::TcpSocket) -> Result<(<T as TcpClientStack>::TcpSocket, SocketAddr), nb::Error<<T as TcpClientStack>::Error>>}
139+
forward! {bind(socket: &mut Self::TcpSocket, port: u16) -> Result<(), <T as TcpClientStack>::Error>}
140+
forward! {listen(socket: &mut Self::TcpSocket) -> Result<(), <T as TcpClientStack>::Error>}
141+
forward! {accept(socket: &mut Self::TcpSocket) -> Result<(<T as TcpClientStack>::TcpSocket, SocketAddr), nb::Error<<T as TcpClientStack>::Error>>}
142142
}

0 commit comments

Comments
 (0)