Giter VIP home page Giter VIP logo

framed-rs's Introduction

framed

Rust crate to send and receive data over lossy streams of bytes.

  • Supports sending slices of bytes or serde-serialized types.
  • Uses a checksum to detect and skip corrupted frames.
  • Includes a command-line tool to decode and display serialized types.

Crate

Documentation: Documentation

This crate should build on the latest Rust stable, beta, and nightly toolchains. When the cargo feature use_std is disabled (requires nightly toolchain), it should also build in embedded projects with no_std.

Development

Source code and issues on GitHub: GitHub last commit

CI build on Travis CI: Build Status

Pull requests welcome.

Sub-crates

  • framed in directory ./framed:

    The core library.

  • framed_decode in directory ./decode:

    A command line tool to decode data encoded by the library. See ./decode/README.md for its documentation.

  • framed_test_type in directory ./test_type:

    A crate for testing framed: a library with encodable types and a binary that outputs encoded data.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

framed-rs's People

Contributors

fluffysquirrels avatar

Stargazers

plein avatar Han Meh avatar Slurpin avatar Rahul Butani avatar Shenghao Yang avatar DiGiTAL_CuRSe avatar  avatar  avatar

Watchers

 avatar James Cloos avatar

framed-rs's Issues

Write a CLI tool that deserializes and prints structs from a pipe

Ideally run it with a script that takes arguments for a crate and struct to deserialize and builds the tool linking to them:

< ./framed_data deframe --type foo::Bar --crate path/to/module/foo

There could be an output type argument to print the deserialized structs with any encoding for which there is a serde Serializer. First few: JSON, CSV, Rust Debug format.

Detect partial frames

The typical approach is for the frame to start with a marker (a zero for COBS), then a length field, then the data, then a checksum, then a zero to end the frame.

If that is too heavyweight we can offer configuration options later e.g. to remove the start byte and length field.

Refine no_std io::{Read, Write} solution

Currently I pull in https://github.com/QuiltOS/core-io, which is not on crates.io. It has std::io-inspired Read and Write traits, but with a generic associated type as an error type.

I've tried and failed to get a version of Sender compiling with no_std and without. The type parameter Write::Err bubbles up to a type parameter on Sender for the no_std version, yet it's not required for the use_std version.

Maybe I just need to work on it some more. If I get core-io working it needs publishing to crates.io, probably as its own crate so it can be re-used in peripherals.

Maybe core-io is too difficult to use here, and I should switch to something else.

The core_io crate doesn't compile out of the box, but should integrate more smoothly.

I could avoid {Read, Write} entirely when no_std, using from_slice, to_slice functions instead.

Move checksum inside COBS

Currently COBS is run on the payload then checksum is appended after this. This can cause errors is the checksum includes the COBS sentinel value.

This could be fixed with current COBS with some fairly intrusive api changes or copying the payload to a temp buffer before calling COBS. However, this PR in COBS exposes a streaming interface that would allow the payload to be encoded, then the checksum, then finalising so no extra copy is necessary.

I'm going to wait for that to be released and submit a PR for framed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.