pub struct CustomCfg {
pub u64s: [u64; 4],
pub usizes: [usize; 4],
pub i32s: [i32; 4],
pub bools: [bool; 4],
pub blob: [u8; 32],
pub blob_len: usize,
}Expand description
Plain-old-data config payload for WorkType::Custom. Every field is
Copy (integers / bools / a fixed byte array) so the whole struct
survives fork() byte-faithfully in the child address space — no heap
pointer, no shared mapping required. Read post-fork by the worker
dispatch and handed to the closure via WorkerCtx::cfg.
Variable-length data is intentionally NOT supported here: a Vec /
String field stores a heap pointer; across fork the pointer is
copied verbatim but the backing buffer is copy-on-write PRIVATE (not
shared), so the child sees its own duplicate, never the parent’s live
data. For variable-length or genuinely shared state, allocate a
MAP_SHARED region in the test body and pass its address through a
u64 slot (see tests/preempt_regression.rs); small inline blobs fit
in blob + blob_len.
Slot meanings are caller-defined — the framework cannot know the schema
of an arbitrary user closure, so it provides indexed typed arrays the
test author assigns meaning to (e.g. u64s[0] = a shared region
address). Construct with CustomCfg::default + the chainable setters.
Fields§
§u64s: [u64; 4]General-purpose 64-bit slots (a common use: a MAP_SHARED region
address as a u64).
usizes: [usize; 4]General-purpose pointer-width slots (sizes, counts, indices).
i32s: [i32; 4]General-purpose signed 32-bit slots (nice levels, fds, flags).
bools: [bool; 4]General-purpose boolean flags.
blob: [u8; 32]Fixed inline byte blob for small variable-length payloads; the valid
prefix length is Self::blob_len.
blob_len: usizeNumber of valid leading bytes in Self::blob (0..=32).
Implementations§
Source§impl CustomCfg
impl CustomCfg
Sourcepub const fn usize_slot(self, i: usize, v: usize) -> Self
pub const fn usize_slot(self, i: usize, v: usize) -> Self
Set slot i of Self::usizes, returning self for chaining.
§Panics
Panics if i >= 4 (the array length).
Sourcepub const fn bool_slot(self, i: usize, v: bool) -> Self
pub const fn bool_slot(self, i: usize, v: bool) -> Self
Set slot i of Self::bools, returning self for chaining.
§Panics
Panics if i >= 4 (the array length).
Sourcepub fn blob(self, bytes: &[u8]) -> Self
pub fn blob(self, bytes: &[u8]) -> Self
Copy up to 32 bytes into Self::blob and set Self::blob_len.
Input longer than 32 bytes is truncated to 32. Non-const (unlike
the integer/bool slot setters) because it copies a runtime slice,
which a const fn cannot express today.
Trait Implementations§
impl Copy for CustomCfg
impl Eq for CustomCfg
impl StructuralPartialEq for CustomCfg
Auto Trait Implementations§
impl Freeze for CustomCfg
impl RefUnwindSafe for CustomCfg
impl Send for CustomCfg
impl Sync for CustomCfg
impl Unpin for CustomCfg
impl UnwindSafe for CustomCfg
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more