hubpack is an algorithm for converting Rust values to bytes and back.

Overview

hubpack: a predictable serde format

hubpack is an algorithm for converting Rust values to bytes and back. It was originally designed for encoding messages sent between embedded programs. It is designed for use with serde.

Some of the nice things about hubpack include:

  • Its encoding format is relatively compact.

  • Its encoding format is predictable. In particular, there are no variable-length integer encodings.

  • Because the size is predictable, hubpack provides a SerializedSize trait. Any type that implements SerializedSize can report the maximum number of bytes necessary to encode it using hubpack. This means you can allocate a fixed-size buffer without worry. (You can #[derive(SerializedSize)] for your own types.)

  • The encode/decode implementations generate fairly small, efficient code.

  • The implementation uses very little unsafe code, only in specific cases with a measurable performance improvement and no reasonable alternative.

You might not want to use hubpack because of the following limitations:

  • hubpack is designed for fixed-size small data structures, and cannot encode things like Vec, str, and maps.

  • hubpack does not support enum types with more than 256 variants.

  • hubpack aims for predictability over compactness, so certain types of data -- like lots of integers whose values are small relative to their types -- can be more compactly encoded using formats like bincode.

You might also like...
A SIMD-accelerated Adler-32 rolling hash algorithm implementation.

simd-adler32 A SIMD-accelerated Adler-32 rolling hash algorithm implementation. Features No dependencies Support no_std (with default-features = false

A Trig-less Line of Sight Algorithm in Two Dimensions

In many examples of 2D line-of-sight algorithms, expensive operations like trigonometry are used. Additionally, some methods have intentional inaccuracies in them for the sake of simplicity. Here, we give an algorithm which does not fudge the numbers, and uses only basic arithmetic: addition, subtraction, multiplication, and division. This is not intended to replace the existing algorithms, or even be more efficient in practice.

An implementation of the A-Star pathfinding algorithm tailored for traversing a bespoke collection of weighted hexagons.
An implementation of the A-Star pathfinding algorithm tailored for traversing a bespoke collection of weighted hexagons.

An implementation of the A-Star pathfinding algorithm tailored for traversing a bespoke collection of weighted hexagons. It's intended to calculate the most optimal path to a target hexagon where you are traversing from the centre of one hexagon to the next along a line orthogonal to a hexagon edge

The labs of Raft consensus algorithm based on MadSim.

MadRaft The labs of Raft consensus algorithm based on MadSim. Some codes are derived from MIT 6.824 and PingCAP Talent Plan: Raft Lab. Thanks for thei

Maximum Relevance - Minimum redundancy feature selection algorithm

mrmr Maximum Relevance - Minimum redundancy feature selection algorithm implemented in Rust. Usage CLI app. It gets input from a csv dataset with head

A simple implementation of the astar pathfinding algorithm from red blob games
A simple implementation of the astar pathfinding algorithm from red blob games

A simple implementation of the astar pathfinding algorithm from red blob games. In order to use the pathfinder you must have a path map for it to navi

nsga is an opinionated implementation of the NSGA-II (Non-dominated Sorting Genetic Algorithm)

nsga nsga is an opinionated implementation of the NSGA-II (Non-dominated Sorting Genetic Algorithm), a multi-objective genetic optimization algorithm.

ANISE provides an open-source and open-governed library and algorithmic specification for most computations for astrodynamics

ANISE provides an open-source and open-governed library and algorithmic specification for most computations for astrodynamics. It is heavily inspired by NAIF SPICE, and may be considered as an open-source modern rewrite of SPICE.

Fast, parallel, extensible and adaptable genetic algorithms framework written in Rust

oxigen Oxigen is a parallel genetic algorithm framework implemented in Rust. The name comes from the merge of OXIdación (Rust translated to Spanish) a

Comments
  • Implement serde::StdError for Error

    Implement serde::StdError for Error

    This allows hubpack to be used by clients who are using serde with its std feature enabled.

    Without this change, using hubpack with serde+std produces errors of the form

       Compiling hubpack v0.1.0 (/hubpack)
    error[E0277]: the trait bound `error::Error: StdError` is not satisfied
       --> /hubpack/src/error.rs:24:6
        |
    24  | impl serde::ser::Error for Error {
        |      ^^^^^^^^^^^^^^^^^ the trait `StdError` is not implemented for `error::Error`
        |
    note: required by a bound in `serde::ser::Error`
       --> /home/john/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.136/src/ser/mod.rs:183:1
        |
    183 | declare_error_trait!(Error: Sized + StdError);
        | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `serde::ser::Error`
        = note: this error originates in the macro `declare_error_trait` (in Nightly builds, run with -Z macro-backtrace for more info)
    

    More detail is here in serde itself: https://github.com/serde-rs/serde/blob/master/serde/src/std_error.rs

    opened by jgallagher 0
  • Deserializing slices

    Deserializing slices

    I've got a vague goal to replace our three-to-four different serialization libraries with hubpack across Hubris, Humility, Idolatry, etc.

    Right now, HIF deserializes slices here, because one of the FunctionValue variants is a slice.

    Unfortunately, this doesn't work with hubpack, which has a DeserializeOwned bound (versus Deserialize in postcard).

    What are the implications of loosening this bound in hubpack?

    opened by mkeeter 1
Owner
Cliff L. Biffle
I'm pretty into this stuff.
Cliff L. Biffle
Example of a genetic algorithm in Rust and Python

Example of a genetic algorithm in Rust and Python Monkey typewriter Finding the phrase 'To be or not to be. That is the question.' Inspired by the exa

sotrh 2 Jan 27, 2022
Execute genetic algorithm (GA) simulations in a customizable and extensible way.

genevo genevo provides building blocks to run simulations of optimization and search problems using genetic algorithms (GA). The vision for genevo is

Innoave 110 Dec 21, 2022
Library that implements different versions of PPMD algorithm (compress and decompress)

ppmd-rs Library that implements different versions of PPMD algorithm (compress and decompress) Dependencies Rust 1.58 or newer Cargo How to build Clon

Alexander Zaitsev 3 Jun 20, 2022
Online algorithm for mean and variance, with support for uneven weights

welford Online algorithm for mean and variance, with support for uneven weights. This implements the Welford's online algorithm for computing mean and

Felipe S. S. Schneider 1 Sep 8, 2022
Genetic Algorithm library in Rust

RsGenetic Summary and Features RsGenetic is a framework for executing genetic algorithms in Rust. It is designed to have a simple but modular API. Exa

Mathieu De Coster 74 Dec 27, 2022
Rust implementation of AstroBWT Proof-Of-Work algorithm

AstroBWT AstroBWT is a proof-of-work (PoW) algorithm based on Burrows-Wheeler transform (BWT). Developed and used by the DERO Project for Mobile (arm)

null 6 Mar 7, 2022
Pure Rust implementation of the Double Ratchet algorithm

Double Ratchet A pure Rust implementation of the Double Ratchet, as specified by Trevor Perrin and Moxie Marlinspike. The Double Ratchet allows two us

Sebastian 52 Nov 25, 2022
A rust implementation of Alexey Akhunov's multiproof algorithm

multiproof.rs A rust implementation of Alexey Akhunov's multiproof algorithm. At the time of creation, multiproof is still a work in progress and this

Guillaume Ballet 30 Aug 24, 2022
A Rust implementation of the AGCWD algorithm

AGCWD is described in the paper "Efficient Contrast Enhancement Using Adaptive Gamma Correction With Weighting Distribution".

Takeru Ohta 2 Jan 17, 2022