Tham chiếu API Nalix.Codec
Trên trang này
Nalix.Codec cung cấp engine tuần tự hóa nhị phân lúc biên dịch (LiteSerializer), danh mục gói tin toàn process (PacketRegistry), factory gói tin có pool (PacketFactory<T>), pipeline biến đổi khung (FramePipeline), nén LZ4 (LZ4Codec), và các nguyên thủy mật mã (EnvelopeCipher, HandshakeX25519, ProofOfWork) cho hệ sinh thái Nalix.
Tuần tự hóa (Nalix.Codec.Serialization)
Nalix dùng bộ tuần tự hóa nhị phân được sinh từ mã nguồn (SerializeFormatterGenerator), được tối ưu cho việc thực thi không cấp phát bộ nhớ và không dùng reflection.
- Serialization Basics:
LiteSerializer,FormatterProvider,IFormatter<T>,IFillableFormatter<T>vàSerializationOptions. - Packet Serialization: Cách các field, auto-property và hình dạng tập hợp của gói tin được mã hóa thành và giải mã từ định dạng wire.
- Serialization Attributes:
[GenerateFormatter],[SerializePackable],[SerializeOrder],[SerializeIgnore],[SerializeHeader]và[SerializeDynamicSize]. - Reader, Writer & Header Extensions:
DataReaderExtensions,DataWriterExtensionsvàHeaderExtensions.AsHeaderRefkhông sao chép dữ liệu.
Gói tin & Registry (Nalix.Codec.DataFrames & Nalix.Codec.ProtocolFrames)
- Packet Registry: Danh mục opcode toàn process với độ phức tạp O(1) (
PacketRegistry.Build(),TryDeserialize,Deserialize,IsKnownOpCode,IsRegistered<T>()). - Frame Model:
FrameBase,PacketBase<TSelf>,FrameTransformer,FrameCiphervàFrameCompression. - Built-in Frames: Cả 11 khung hệ thống và khung bắt tay tích hợp sẵn (
Control,Directive,TimeSync,SessionInit,SessionChallenge,SessionProof,SessionEstablished,SessionResume,SessionTofu,ProofOfWorkChallenge,ProofOfWorkProof). - Fragmentation: Tách và ghép lại payload lớn (
FragmentHeader,FragmentAssembler,FragmentOptions,FragmentStreamIdtrongNalix.Environment.Fragments).
Biến đổi khung & Mật mã (Nalix.Codec.Transforms & Nalix.Codec.Security)
- Frame Pipeline: Biến đổi khung inbound (giải mã $\rightarrow$ giải nén) và outbound (nén $\rightarrow$ mã hóa) hợp nhất qua
FramePipeline. - LZ4 Compression: Nén/giải nén khối LZ4 dựa trên span và
BufferLeasecó pool (LZ4Codec,LZ4BlockHeader,CompressionOptions). - Cryptography Overview:
EnvelopeCipher,ChaCha20Poly1305,Salsa20Poly1305,HandshakeX25519,ProofOfWork,Keccak256,HmacKeccak256vàPbkdf2.
Tùy chọn cấu hình (Nalix.Codec.Options)
CompressionOptions([Compression]):Enabled = true,MinSizeToCompress = 512,MaxDecompressedSize = 33_554_432(32 MB).SerializationOptions([Serialization]):MaxArrayLength = 1_048_576,MaxStringLength = 1_048_576,MaxDeserializationDepth = 256.SecurityOptions([Security]):Pbkdf2Iterations = 310_000.