Skip to content

Commit e103a3c

Browse files
committed
add IpStack::abort method
1 parent 22ae9dc commit e103a3c

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl IpStackConfig {
8383

8484
pub struct IpStack {
8585
accept_receiver: UnboundedReceiver<IpStackStream>,
86-
_handle: JoinHandle<Result<()>>, // Just hold the task handle
86+
handle: JoinHandle<Result<()>>,
8787
}
8888

8989
impl IpStack {
@@ -94,13 +94,17 @@ impl IpStack {
9494
let (accept_sender, accept_receiver) = mpsc::unbounded_channel::<IpStackStream>();
9595
IpStack {
9696
accept_receiver,
97-
_handle: run(config, device, accept_sender),
97+
handle: run(config, device, accept_sender),
9898
}
9999
}
100100

101101
pub async fn accept(&mut self) -> Result<IpStackStream, IpStackError> {
102102
self.accept_receiver.recv().await.ok_or(IpStackError::AcceptError)
103103
}
104+
105+
pub fn abort(self) {
106+
self.handle.abort();
107+
}
104108
}
105109

106110
fn run<Device: AsyncRead + AsyncWrite + Unpin + Send + 'static>(

0 commit comments

Comments
 (0)