mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-26 00:00:16 +02:00
codec: change Encoder to take &Item (#1746)
Co-authored-by: Markus Westerlind <[email protected]>
This commit is contained in:
co-authored by
Markus Westerlind
parent
1eb6131321
commit
9d4d076189
@@ -182,11 +182,14 @@ impl Decoder for LinesCodec {
|
||||
}
|
||||
}
|
||||
|
||||
impl Encoder for LinesCodec {
|
||||
type Item = String;
|
||||
impl<T> Encoder<T> for LinesCodec
|
||||
where
|
||||
T: AsRef<str>,
|
||||
{
|
||||
type Error = LinesCodecError;
|
||||
|
||||
fn encode(&mut self, line: String, buf: &mut BytesMut) -> Result<(), LinesCodecError> {
|
||||
fn encode(&mut self, line: T, buf: &mut BytesMut) -> Result<(), LinesCodecError> {
|
||||
let line = line.as_ref();
|
||||
buf.reserve(line.len() + 1);
|
||||
buf.put(line.as_bytes());
|
||||
buf.put_u8(b'\n');
|
||||
|
||||
Reference in New Issue
Block a user