Pamoja.Codec 0.1.18

There is a newer version of this package available.
See the version list below for details.
dotnet add package Pamoja.Codec --version 0.1.18
                    
NuGet\Install-Package Pamoja.Codec -Version 0.1.18
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Pamoja.Codec" Version="0.1.18" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Pamoja.Codec" Version="0.1.18" />
                    
Directory.Packages.props
<PackageReference Include="Pamoja.Codec" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Pamoja.Codec --version 0.1.18
                    
#r "nuget: Pamoja.Codec, 0.1.18"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Pamoja.Codec@0.1.18
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Pamoja.Codec&version=0.1.18
                    
Install as a Cake Addin
#tool nuget:?package=Pamoja.Codec&version=0.1.18
                    
Install as a Cake Tool

Pamoja.Codec

CBOR, JSON, and raw codecs behind one trait, delta and varint batch packing, and an f32 quantizer for metered links. One capability of pamoja, one memory-safe Rust core with bindings for TypeScript, Python, and C#.

read the guide documentation API reference

Install

dotnet add package Pamoja.Codec
using Pamoja.Codec;

This pulls in Pamoja.Native, the compiled engine. dotnet add package Pamoja is the whole framework in one package.

Example

The guide project's example, spliced here as it ran in CI.

From bindings/dotnet/samples/Pamoja.Guides/CodecGuide.cs:

// The same reading as JSON and as CBOR. Nothing is lost, and 21.5 rides as a
// half-precision float, the shortest form RFC 8949 allows for it.
byte[] asJson = Encoding.UTF8.GetBytes("{\"c\":21.5,\"ok\":true}");
byte[] cbor = Codec.JsonToCbor(asJson);
Console.WriteLine($"json      {asJson.Length} bytes");
Console.WriteLine($"cbor      {cbor.Length} bytes");

// A gateway that speaks JSON gets it back unchanged, so the compact form is a
// transport choice rather than a different data model.
byte[] restored = Codec.CborToJson(cbor);
Console.WriteLine($"back to json, unchanged: {restored.SequenceEqual(asJson)}");

// A batch of readings packs to a count, then the difference between each sample
// and the one before it. Successive readings differ by very little, so the
// differences cost about a byte each where the samples would cost eight.
long[] samples = [10, 11, 13, 12, 900];
byte[] packed = Codec.PackSamples(samples);
Console.WriteLine($"batch     {samples.Length} samples in {packed.Length} bytes");
Console.WriteLine($"unpacked  {string.Join(", ", Codec.UnpackSamples(packed))}");

// Readings that arrive as floats pack the same way once a scale is chosen. Nothing
// in the bytes records that scale, so sender and receiver have to agree on it.
var quantizer = new Quantizer(100.0f);
float[] celsius = [20.0f, 20.1f, 20.2f, 20.3f];
byte[] packedCelsius = quantizer.Encode(celsius);
float[] recovered = quantizer.Decode(packedCelsius);
Console.WriteLine($"degrees   {celsius.Length} readings in {packedCelsius.Length} bytes");
Console.WriteLine($"recovered {string.Join(", ", recovered.Select(v => v.ToString("F1")))}");

The same capability in every language

Language Package Reference
Rust pamoja-codec reference, docs.rs, install
TypeScript @pamoja/codec reference, install
Python pamoja-codec reference, install
C# Pamoja.Codec reference, install

Documentation

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (9)

Showing the top 5 NuGet packages that depend on Pamoja.Codec:

Package Downloads
Pamoja

The whole pamoja framework in one package: every capability of one memory-safe Rust core, behind an idiomatic C# facade, for IoT, robotics, and drones.

Pamoja.Sync

Offline-first queues in memory or on disk, bounded or not, the on-disk one surviving power loss, and the drain that forwards them in order when a link returns.

Pamoja.Lorawan

LoRaWAN 1.0.x MAC framing, AES-CMAC and AES encryption, and both halves of the OTAA join.

Pamoja.Sim

Noisy and replay sensors, a recording actuator, a simulated robot that dead-reckons its pose, and a link that loses sends on a pattern.

Pamoja.Serial

SLIP and COBS byte stuffing with streaming decoders, so a UART byte stream carries discrete packets.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.0 324 9/24/2026
0.1.18 326 9/11/2026
0.1.17 326 9/6/2026
0.1.16 325 9/5/2026
0.1.15 320 9/5/2026