vorner / tokio-serde-cbor Goto Github PK
View Code? Open in Web Editor NEWTokio codec for serde-cbor
License: Apache License 2.0
Tokio codec for serde-cbor
License: Apache License 2.0
Because Decoder and Encoder contain a PhantomData<*const Item>
field, all three structs are !Send + !Sync
. This prevents any of them from being used with a thread pool. Shouldn't the phantom data just be PhantomData<Item>
? Neither the encoder nor the decoder have an internal state, as they simply read whole items from or write whole items to a buffer provided by the caller.
Hi,
I'm trying to use this for ipc, but I can't get it to work, and found no examples or doc, or unit tests that show how this works with tokio streams... I can't figure out how I should use this. The code almost identical works with a LinesCodec (without using serde, just sending strings).
This is what I got: https://github.com/najamelan/test_uds_tokio/blob/DecodeError/src/libpeers/ipc_peer.rs
Basically the codec gets setup in the new method.
The reading happens in the listening method.
The writing happens in the Handler impl.
IpcMessage is a simple struct that derives serde Serialize/Deserialize.
If you want to run it, use cargo run --bin peera
. peerb.rs does the sending. peera.rs the receiving end.
I always get this error:
Error extracting IpcMessage from stream
Cbor(
ErrorImpl {
code: Message(
"invalid type: byte array, expected struct IpcMessage"
),
offset: 0
}
)
Thanks in advance for your help.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.