mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 06:16:04 +00:00
Military-grade server implementation (#40)
* Military-grade server implementation * Add doc comments
This commit is contained in:
parent
6eee543a33
commit
9f78b3f4a7
1 changed files with 23 additions and 1 deletions
|
@ -302,7 +302,8 @@ where
|
|||
R1: ProtocolPacket + Debug,
|
||||
W1: ProtocolPacket + Debug,
|
||||
{
|
||||
fn from<R2, W2>(connection: Connection<R1, W1>) -> Connection<R2, W2>
|
||||
/// Creates a `Connection` of a type from a `Connection` of another type. Useful for servers or custom packets.
|
||||
pub fn from<R2, W2>(connection: Connection<R1, W1>) -> Connection<R2, W2>
|
||||
where
|
||||
R2: ProtocolPacket + Debug,
|
||||
W2: ProtocolPacket + Debug,
|
||||
|
@ -323,4 +324,25 @@ where
|
|||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert an existing `TcpStream` into a `Connection`. Useful for servers.
|
||||
pub fn wrap(stream: TcpStream) -> Connection<R1, W1> {
|
||||
let (read_stream, write_stream) = stream.into_split();
|
||||
|
||||
Connection {
|
||||
reader: ReadConnection {
|
||||
read_stream,
|
||||
buffer: BytesMut::new(),
|
||||
compression_threshold: None,
|
||||
dec_cipher: None,
|
||||
_reading: PhantomData,
|
||||
},
|
||||
writer: WriteConnection {
|
||||
write_stream,
|
||||
compression_threshold: None,
|
||||
enc_cipher: None,
|
||||
_writing: PhantomData,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue