Giter Site home page Giter Site logo

vhl's Introduction

WireWeaver

WireWeaver is a wire format and API code generator for resource constrained systems (for example microcontrollers). It allows you to define data types, methods, properties or streams and generate code that uses no standard library or memory allocation. Backwards and forwards compatibility is supported: devices with older format version can communicate with newer ones and vice versa.

Currently only Rust language is supported, with the idea to handle device communications in Rust and provide higher level bindings for C++, Python or other languages if needed.

Current state is - highly experimental.

Supported types

  • Boolean: bool

  • Discrete numbers:

    • Signed: i8, i16, i32, i64, i128
    • Unsigned: u4, u8, u16, u32, u64, u128
  • Variable length encoded numbers: leb<T>, nib<u32>

  • Floating point numbers: f32, f64

  • Textual:

    • UTF-8 string str, or with max bounded length: str<N> (N in bytes)
  • Sequences:

    • Arrays:
      • Fixed length array: [T; N]
      • Arbitrary length array: vec<T> or max bounded: vec<T, N>
  • Option<T> and Result<T, E>

  • User-defined:

    • Struct
    • Enum with data variants
  • Not yet supported or not decided whether to support:

    • Tuple
    • Unicode character: char (4B)
    • ASCII character c_char (1B) (ASCII) and string: c_str
    • Map
    • Bitfield

Bounded numbers

Simple checked numbers where only a range of values is allowed:

  • u16<{1..=512}>

Set of allowed values:

  • u8<{0..=8}, 12, 16, 20, 24, 32, 48, 64>

Numbers are checked before serialization and after deserialization.

SI support

Specify SI unit for any number:

  • current: f32<"A">
  • velocity: f32<"m/s">

Units are not transmitted over the wire, used as a hint for code generation and in UI tool.

Syntax

Rust syntax is reused with addition of several attributes.

Wire format definition

Struct fields are laid out in order, as defined or according to provided id.

Only one wire format is currently being worked on targeted at microcontroller usage: wfdb. Features:

  • 1 byte alignment
  • Support all types described above
  • Booleans can take 1 bit, 4 bit or 1B of space, see pre-conditions below.
  • u4 / nibble based variable length numbers used for array length

API

Define a custom protocol as collections of methods, properties or streams and generate server and client side code. Event based communication model is used. Generated code will perform protocol compatibility checks.

Under the hood API code generator uses a WireWeaver definition of Event. Custom Event type can also be provided?

Versioning

Each file containing WireWeaver code must be saved with a version appended after it's name. Before code generation, compatibility check is performed to ensure backwards and forward compatibility.

UI utility

Features:

  • Support for bytecode loading in order to extract types and api information
  • Support for source loading from external sources and compiling to bytecode (through Rust lib FFI or backend service)
  • Provide input and output widgets for various types (number with SI support as spinner / dial / slide, string, color, ...)
  • Generate documentation like UI with the ability to interact with server code
  • Generate server mockup UI with ability to respond with user input, prerecorded answers or examples

CLI utility

Utility for generating code, documentation, publishing to the repository. Main way to invoke WireWeaver in Rust is through procedural macros, no CLI tool calls are required.

Repository

Public repository for common dependencies and unique protocol IDs.

vhl's People

Contributors

romixlab avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

vhl's Issues

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.