Skip to content

Commit

Permalink
Remove Packet::into_bytes and add Packet::to_bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
oblique committed Dec 12, 2020
1 parent 8137eb9 commit 14707d7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl<'a> Packet<'a> {
buf.put_u16(block_id);
}

pub(crate) fn into_bytes(self) -> Bytes {
pub(crate) fn to_bytes(&self) -> Bytes {
let mut buf = BytesMut::new();
self.encode(&mut buf);
buf.freeze()
Expand Down
2 changes: 1 addition & 1 deletion src/server/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ async fn send_error(error: Error, peer: SocketAddr) -> Result<()> {
let addr: SocketAddr = "0.0.0.0:0".parse().unwrap();
let socket = Async::<UdpSocket>::bind(addr).map_err(Error::Bind)?;

let data = Packet::Error(error.into()).into_bytes();
let data = Packet::Error(error.into()).to_bytes();
socket.send_to(&data[..], peer).await?;

Ok(())
Expand Down

0 comments on commit 14707d7

Please sign in to comment.