Skip to main content

CloneableDep

Trait CloneableDep 

Source
pub trait CloneableDep:
    Sized
    + Send
    + Sync
    + 'static {
    // Required methods
    fn to_wire(&self) -> Vec<u8> ;
    fn from_wire(bytes: &[u8]) -> Self;
}
Expand description

User-facing trait that opts a dependency value into the Cloneable sharing strategy. The parent calls to_wire once and ships the bytes to each worker via IPC. Each worker calls from_wire to reconstruct a local value.

The on-the-wire encoding is entirely up to the implementor: serde_json, bincode, postcard, a hand-rolled binary format, an on-disk file path, etc. The bytes are treated as opaque by the runner.

The simple Self-returning from_wire covers Cloneable deps that need no other worker-local context. If reconstruction needs worker-local state (for example, a per-worker engine), model that state as a separate dependency and combine the two from the test or a higher-level helper.

Required Methods§

Source

fn to_wire(&self) -> Vec<u8>

Serialise this value into wire bytes for transmission to workers.

Source

fn from_wire(bytes: &[u8]) -> Self

Reconstruct a value from wire bytes received from the parent.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§