Comments (2)
@uberblah is it enough for you? I may do some more fixes.
pub trait UdpCodec {
/// The type of decoded frames.
type In;
/// The type of frames to be encoded.
type Out;
/// The type of unrecoverable frame encoding/decoding errors.
///
/// `From<io::Error>` is required in the interest of making `Error` suitable
/// for returning directly from a `FramedRead`, and to enable the default
/// implementation of `decode_eof` to yield an `io::Error` when the decoder
/// fails to consume all available data.
///
/// Note that implementors of this trait can simply indicate `type Error =
/// io::Error` to use I/O errors as this type.
type Error: From<io::Error>;
/// Attempts to decode a frame from the provided buffer of bytes.
///
/// This method is called by `UdpFramed` on a single datagram which has been
/// read from a socket. The `buf` argument contains the data that was
/// received from the remote address, and `src` is the address the data came
/// from. Note that typically this method should require the entire contents
/// of `buf` to be valid or otherwise return an error with trailing data.
///
/// Finally, if the bytes in the buffer are malformed then an error is
/// returned indicating why. This informs `Framed` that the stream is now
/// corrupt and should be terminated.
fn decode(&mut self, src: &SocketAddr, buf: &[u8]) -> Result<Self::In, Self::Error>;
/// Encodes a frame into the buffer provided.
///
/// This method will encode `msg` into the byte buffer provided by `buf`.
/// The `buf` provided is an internal buffer of the `Framed` instance and
/// will be written out when possible.
///
/// The encode method also determines the destination to which the buffer
/// should be directed, which will be returned as a `SocketAddr`.
fn encode(&mut self, msg: Self::Out, buf: &mut Vec<u8>) -> Result<SocketAddr, Self::Error>;
}
from tokio.
That would be excellent! Thank you!
from tokio.
Related Issues (20)
- TcpListener::bind faild on windows server 2008 64-bit (Windows) HOT 4
- `block_in_place` + `block_on` can hang on runtime shutdown / runtime drop HOT 4
- Test worker_steal_count hangs sometimes
- feature request - provide a Receive trait for the recv() method for all the different channel receivers. HOT 1
- Create a macro to support parameterized tests HOT 1
- Use `wasm32-wasip1` target
- Document `Runtime::metrics`
- Consider implementing JoinHandle::try_join HOT 1
- Clarify how watch::Sender subscribe() and closed() methods interact
- When specific conditions arise, the task does not behave as intended within a spawned task HOT 1
- Catch infinite recursion HOT 3
- Tokio select! Macro Issue with Barrier HOT 1
- On docs.rs, ‘time::pause’ and ‘time::resume’ no longer state requirement on feature test-util HOT 1
- Support wasi-cli (stdin, stdout)
- Reduce contention in timer driver HOT 12
- JoinHandle wakers are kept alive longer than necessary
- Proposal provide support for notifying the latest added waiter (LIFO) for the Notify interface HOT 15
- CI fails to download files HOT 4
- Support stdin/stdout (io-std feature) in WASM HOT 5
- Bad completion of some futures in io::copy_bidirectional HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tokio.