pub struct KdbCodec { /* private fields */ }Expand description
Kdb+ Protocol Codec
This codec handles encoding and decoding of kdb+ IPC messages. It manages the message framing, compression, and serialization/deserialization of K objects.
Implementations§
Source§impl KdbCodec
impl KdbCodec
Sourcepub fn new(is_local: bool) -> Self
pub fn new(is_local: bool) -> Self
Create a new KdbCodec with default settings (Auto compression, Strict validation)
§Parameters
is_local: Whether the connection is within the same host (affects compression in Auto mode)
Sourcepub fn with_options(
is_local: bool,
compression_mode: CompressionMode,
validation_mode: ValidationMode,
) -> Self
pub fn with_options( is_local: bool, compression_mode: CompressionMode, validation_mode: ValidationMode, ) -> Self
Create a new KdbCodec with custom compression and validation modes
§Parameters
is_local: Whether the connection is within the same host (affects compression in Auto mode)compression_mode: How to handle message compressionvalidation_mode: How strictly to validate incoming messages
§Example
use kdb_codec::{KdbCodec, CompressionMode, ValidationMode};
// Always compress, lenient validation
let codec = KdbCodec::with_options(false, CompressionMode::Always, ValidationMode::Lenient);Sourcepub fn set_compression_mode(&mut self, mode: CompressionMode)
pub fn set_compression_mode(&mut self, mode: CompressionMode)
Set the compression mode
Sourcepub fn compression_mode(&self) -> CompressionMode
pub fn compression_mode(&self) -> CompressionMode
Get the current compression mode
Sourcepub fn set_validation_mode(&mut self, mode: ValidationMode)
pub fn set_validation_mode(&mut self, mode: ValidationMode)
Set the validation mode
Sourcepub fn validation_mode(&self) -> ValidationMode
pub fn validation_mode(&self) -> ValidationMode
Get the current validation mode
Sourcepub fn builder() -> KdbCodecBuilder
pub fn builder() -> KdbCodecBuilder
Create a builder for KdbCodec with fluent API
§Example
use kdb_codec::{KdbCodec, CompressionMode, ValidationMode};
// Using builder pattern
let codec = KdbCodec::builder()
.is_local(false)
.compression_mode(CompressionMode::Always)
.validation_mode(ValidationMode::Lenient)
.build();Trait Implementations§
Source§impl Decoder for KdbCodec
impl Decoder for KdbCodec
Source§type Item = KdbMessage
type Item = KdbMessage
The type of decoded frames.
Source§fn decode(&mut self, src: &mut BytesMut) -> Result<Option<Self::Item>>
fn decode(&mut self, src: &mut BytesMut) -> Result<Option<Self::Item>>
Attempts to decode a frame from the provided buffer of bytes. Read more
Auto Trait Implementations§
impl Freeze for KdbCodec
impl RefUnwindSafe for KdbCodec
impl Send for KdbCodec
impl Sync for KdbCodec
impl Unpin for KdbCodec
impl UnwindSafe for KdbCodec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more