pub trait CodecLayer: 'static {
type ConnState: Default + 'static;
type WriteBuf: WriteBufStorage;
const IS_PASSTHROUGH: bool;
// Required methods
fn is_active(state: &Self::ConnState) -> bool;
fn process_inbound(state: &mut Self::ConnState, wire_in: &[u8]);
fn process_outbound(state: &mut Self::ConnState, plaintext_in: &[u8]);
fn take_plaintext(state: &mut Self::ConnState) -> Vec<u8> ⓘ;
fn install_plaintext(state: &mut Self::ConnState, plaintext: Vec<u8>);
fn take_inflight(state: &mut Self::ConnState) -> Option<(*const u8, u32)>;
fn consume_inflight(state: &mut Self::ConnState, n: usize) -> bool;
fn has_inflight(state: &Self::ConnState) -> bool;
fn wire_slice(state: &Self::ConnState) -> &[u8] ⓘ;
fn close_pending(state: &Self::ConnState) -> bool;
}Expand description
Pool-side dispatch for a connection’s wire-flow.
Two kinds of impls exist:
- Passthrough —
Plain.IS_PASSTHROUGH = true,WriteBuf = ()(ZST, no per-slot staging cost), all codec methods are no-ops because pool skips them via the const branch. - Codec — e.g.
dope_tls::TlsCodec.IS_PASSTHROUGH = false,WriteBuf = WriteBufArr, all codec methods do real work.
Pool generics are over L: CodecLayer. Real codecs implement this trait
directly — there is no separate Codec / Coded<C> indirection.
Protocols that require a non-passthrough layer (e.g. a PostgreSQL client that performs STARTTLS) bound on the concrete layer type:
ⓘ
type CodecLayer = dope_tls::LazyTlsCodec;Required Associated Constants§
Sourceconst IS_PASSTHROUGH: bool
const IS_PASSTHROUGH: bool
True if this layer bypasses the codec staging path. Pool branches on this const to pick the direct fill_msghdr path (passthrough) vs the write_buf → process_outbound → take_inflight path (codec). The branch is monomorphized → DCE.
Required Associated Types§
Required Methods§
fn is_active(state: &Self::ConnState) -> bool
fn process_inbound(state: &mut Self::ConnState, wire_in: &[u8])
fn process_outbound(state: &mut Self::ConnState, plaintext_in: &[u8])
fn take_plaintext(state: &mut Self::ConnState) -> Vec<u8> ⓘ
fn install_plaintext(state: &mut Self::ConnState, plaintext: Vec<u8>)
fn take_inflight(state: &mut Self::ConnState) -> Option<(*const u8, u32)>
fn consume_inflight(state: &mut Self::ConnState, n: usize) -> bool
fn has_inflight(state: &Self::ConnState) -> bool
fn wire_slice(state: &Self::ConnState) -> &[u8] ⓘ
fn close_pending(state: &Self::ConnState) -> bool
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.