Nalix.Codec
13.0.0
dotnet add package Nalix.Codec --version 13.0.0
NuGet\Install-Package Nalix.Codec -Version 13.0.0
<PackageReference Include="Nalix.Codec" Version="13.0.0" />
<PackageVersion Include="Nalix.Codec" Version="13.0.0" />
<PackageReference Include="Nalix.Codec" />
paket add Nalix.Codec --version 13.0.0
#r "nuget: Nalix.Codec, 13.0.0"
#:package Nalix.Codec@13.0.0
#addin nuget:?package=Nalix.Codec&version=13.0.0
#tool nuget:?package=Nalix.Codec&version=13.0.0
Nalix.Codec
High-performance data transformation and framing engine.
Nalix.Codec provides the unified pipeline for data handling in Nalix. It orchestrates serialization, LZ4 compression, AEAD cryptography, and protocol framing into a cohesive, high-throughput transform chain.
Core Features
| Feature | Description |
|---|---|
| 🛡️ Security Engine | Hardened AEAD cryptography (Chacha20Poly1305, Salsa20Poly1305) and secure X25519 handshake. |
| 📦 Packet System | Highly optimized PacketBase<TPacket> and FrameBase primitives with integrated buffer pooling. |
| 🗜️ Compression | High-speed, zero-allocation custom pool-backed LZ4 block compression. |
| ⛓️ Frame Pipeline | Multi-layered orchestrated transformation pipelines (e.g., Serialize → Compress → Encrypt). |
Key Namespaces
| Namespace | Purpose | Key Types |
|---|---|---|
Nalix.Codec.DataFrames |
High-performance data framing and runtime packet registry | PacketBase<TPacket>, FrameBase, PacketRegistry, PacketSchema |
Nalix.Codec.ProtocolFrames |
Specialized low-level framing for control, directives, handshakes, and key exchanges | Control, Directive, Handshake, KeyExchange, SessionResume |
Nalix.Codec.Transforms |
Orchestrated pipelines and transformers sequencing compression and encryption | FrameTransformer, FramePipeline, FrameCompression, FrameCipher |
Nalix.Codec.Serialization |
Zero-allocation source-generated binary serialization and formatters | LiteSerializer, FormatterProvider, IFormatter<T>, IFillableFormatter<T> |
Nalix.Codec.Security |
Cryptographic algorithms, envelope ciphers, and key exchange layers | HandshakeX25519, EnvelopeCipher |
Nalix.Codec.Security.Symmetric |
Optimized C# stream cipher implementations | ChaCha20, Salsa20 |
Nalix.Codec.Security.Hashing |
Custom high-performance hash functions, message authenticators, and PBKDF2 | Poly1305, Keccak256, Pbkdf2, HmacKeccak256 |
Nalix.Codec.LZ4 & .Engine |
High-performance stream/block compression and encoder pools | LZ4BlockEncoder, LZ4Codec, LZ4Encoder, LZ4Decoder, LZ4HashTablePool |
Nalix.Codec.Pooling |
Scoped allocation lifecycle guards and factories | PacketScope, PacketFactory |
Installation
dotnet add package Nalix.Codec
Quick Example: Packet Definition
using Nalix.Abstractions.Networking.Packets;
using Nalix.Abstractions.Serialization;
using Nalix.Codec.DataFrames;
[Packet]
[GenerateFormatter]
[SerializePackable(SerializeLayout.Explicit)]
public partial class MyPacket : PacketBase<MyPacket>
{
[SerializeOrder(0)]
public string Message { get; set; } = string.Empty;
public MyPacket()
{
this.OpCode = 101; // Assign custom opcode
}
}
Quick Example: Using LiteSerializer
using System;
using Nalix.Codec.Serialization;
// Create a custom serializable packet instance
MyPacket packet = new MyPacket { Message = "Hello Nalix!" };
// Serialize the packet into a byte array
byte[] encoded = LiteSerializer.Serialize(packet);
// Deserialize the byte array back to the packet type
MyPacket decoded = LiteSerializer.Deserialize<MyPacket>(encoded, out int bytesRead);
Console.WriteLine($"Decoded Message: {decoded.Message} (Read {bytesRead} bytes)");
Performance Principles
- Zero-Allocation: All hot paths use
Span<byte>and pooled buffers. - No Reflection: Serialization is handled via compile-time source generation.
- Memory Efficient: Uses
BufferLeaseand reference counting for large data payloads.
Documentation
For technical details on the transform pipeline and packet schema, see the Codec API Reference.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Nalix.Abstractions (>= 13.0.0)
- Nalix.Environment (>= 13.0.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Nalix.Codec:
| Package | Downloads |
|---|---|
|
Nalix.SDK
Nalix.SDK provides the client-side development kit for the Nalix ecosystem, offering high-level APIs, transport sessions (TCP, UDP, and WebSockets), time synchronization helpers, and typed message subscription models for building distributed applications. It acts as the bridge between application logic and the Nalix.Network layer, simplifying remote communication, configuration, and message orchestration through clean, extensible, and developer-friendly interfaces. |
|
|
Nalix.Runtime
Nalix.Runtime provides the core packet processing and middleware infrastructure for the Nalix ecosystem. It includes the middleware pipeline orchestration, packet dispatching channels, and execution management needed to handle message-oriented traffic with high efficiency and low latency. It serves as the foundation for building complex message-processing workflows, offering a modular and extensible architecture that decouples transport logic from application-level packet handling. |
|
|
Nalix.Hosting
Nalix.Hosting provides Microsoft-style host and builder APIs for the Nalix ecosystem. It wires configuration loading, diagnostic event bridging, packet dispatch, and TCP/UDP listener lifecycle into a familiar builder/build/start workflow for quickly bootstrapping Nalix-based servers. |
GitHub repositories
This package is not used by any popular GitHub repositories.
- Pipeline-Oriented Architecture: Unified Serialization, Compression, and Security into a cohesive Codec stack.
- High-Performance Framing: Integrated DataFrames (PacketBase, FrameBase) and structured ProtocolFrames for unified control and data transport.
- Advanced Cryptography: Hardened AEAD engines (Chacha20Poly1305/Salsa20Poly1305) and high-speed X25519 key exchange.
- Optimized Serialization: Refined LiteSerializer with source-generated codecs for complex types and fast unmanaged paths.
- Efficient Compression: Integrated LZ4 block encoders with custom memory pool support to minimize GC pressure.