mirror of
https://github.com/GiriNeko/hbb_common.git
synced 2025-12-16 21:37:27 +00:00
commit
3afaf64944
1 changed files with 6 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::{config, tcp, websocket, ResultType};
|
use crate::{config, tcp, websocket, ResultType};
|
||||||
use sodiumoxide::crypto::secretbox::Key;
|
use sodiumoxide::crypto::secretbox::Key;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
|
use tokio::net::TcpStream;
|
||||||
|
|
||||||
// support Websocket and tcp.
|
// support Websocket and tcp.
|
||||||
pub enum Stream {
|
pub enum Stream {
|
||||||
|
|
@ -107,4 +108,9 @@ impl Stream {
|
||||||
Self::Tcp(tcp) => tcp.local_addr(),
|
Self::Tcp(tcp) => tcp.local_addr(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn from(stream: TcpStream, stream_addr: SocketAddr) -> Self {
|
||||||
|
Self::Tcp(tcp::FramedStream::from(stream, stream_addr))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue