completed basic implementation of FramedUdp for streams and sink

This commit is contained in:
Rick Richardson
2016-11-19 09:05:00 -08:00
parent 0f49a69a06
commit 592a99bca4
2 changed files with 272 additions and 0 deletions
+14
View File
@@ -42,6 +42,20 @@ impl UdpSocket {
UdpSocket::new(udp, handle)
}
/// Creates a FramedUdp object, which leverages a supplied `EncodeUdp`
/// and `DecodeUdp` to implement `Stream` and `Sink`
/// This moves the socket into the newly created FramedUdp object
pub fn framed<D, E>(self, decoder : D, encoder : E) -> Framed<D, E> {
FramedUdp {
socket: self,
encoder: encoder,
decoder: decoder,
is_readable: false,
rd: Vec::with_capacity(64 * 1024);
wr: Vec::with_capacity(64 * 1024),
}
}
/// Returns the local address that this stream is bound to.
pub fn local_addr(&self) -> io::Result<SocketAddr> {
self.io.get_ref().local_addr()