Skip to main content

CuTwinBuilder

Struct CuTwinBuilder 

Source
pub struct CuTwinBuilder<A, R> { /* private fields */ }
Expand description

Builder for a generated application’s live twin. Copper owns all worker, routing, archive, and recovery plumbing; callers supply a packet transport. Receiver bounds match the default 1200-byte-MTU, 64-symbol streaming profile. One handle accepts one sender session, with a fresh archive path.

Implementations§

Source§

impl<A: LiveReplay, R: CuStreamRx + 'static> CuTwinBuilder<A, R>

Source

pub fn with_feedback<T: CuFeedbackTx + 'static>(self, tx: T) -> Self

Enable feedback only when the sender advertises support. The caller owns endpoint selection.

Source

pub fn with_log_path(self, path: impl AsRef<Path>) -> Self

Source

pub fn with_log_rollover(self, bytes: usize) -> Self

Bound archive storage in bytes, overwriting the oldest data sections. Static application metadata and the decode catalog remain available. Capacity must exceed the configured section size and be a multiple of 512 bytes.

Source

pub fn with_slab_size(self, bytes: usize) -> Self

Sets the size of each archive backing file (slab), in bytes. Defaults to 16 MiB.

The archive adds another slab when the current one fills; this is not a limit on total recording size. A slab must fit the largest section used to store CopperLists, keyframes, or structured logs. Prefer a slab roughly 10–100 times larger than a section to hold many sections per file and reduce file turnover. Larger slabs reserve more disk space at a time. Both slab and section sizes must be multiples of 512 bytes.

Source

pub fn with_section_size(self, bytes: usize) -> Self

Sets the size of an archive section, in bytes. Defaults to 128 KiB.

Sections group records such as CopperLists, keyframes, and structured log entries inside a slab. A complete record must fit within one section. Choose at least the larger of max_record_bytes and finite_objects.max_object_bytes from Self::with_receiver_limits, plus 512 bytes for the section header and 32 bytes for the archive’s continuity envelope. Round up to a multiple of 512 bytes.

Increase this alongside receive bounds when captures or task-state snapshots grow. The section must fit in Self::with_slab_size; keeping slabs much larger lets each file hold many sections.

Source

pub fn with_receiver_limits(self, limits: SessionRouterLimits) -> Self

Sets receive size and buffering limits for one sender session. Defaults to SessionRouterLimits::default.

max_record_bytes bounds one complete serialized CopperList record (default: 4 KiB). finite_objects.max_object_bytes bounds one manifest, keyframe, or structured log record (default: 64 KiB). Match or exceed the sender’s advertised bounds so its captures and recovery snapshots can be received, and increase Self::with_section_size to fit them.

The remaining limits bound records, packets, recovery data, and objects buffered during decoding. Larger sizes and concurrency limits increase receiver memory use; they are not a total process memory budget. max_sessions must be 1. The packet profile remains a 1200-byte MTU with at most 1128-byte symbols and 64 FEC equations.

Source

pub fn with_replay_capacity(self, capacity: NonZeroUsize) -> Self

Sets buffering between recording and task replay. Defaults to 32.

This bounds both the queued replay events (captured CopperLists and recovery keyframes) and the pending CopperLists waiting for matching replay state. One recovery keyframe and one executing CopperList are retained in addition to these buffers.

Increase this to absorb short replay slowdowns; reduce it to retain fewer payloads in memory. Overflow interrupts reconstruction until a matching recovery point is available. Received data continues to be recorded in the archive. This setting is unused with Self::archive_only.

Source

pub fn with_log_capacity(self, capacity: NonZeroUsize) -> Self

Sets the number of unread structured log entries buffered for CuTwin::take_log_reader. Defaults to 64 entries.

These are the robot’s structured logging calls (such as info! and debug!), published after being saved in the archive. Increase this to let the log reader pause longer at the cost of retaining more entries in memory. When full, the buffer replaces the oldest unread entry. Reading slowly never blocks recording; overwritten entries remain in the archive.

Source

pub fn with_frame_capacity(self, capacity: NonZeroUsize) -> Self

Sets the number of unread reconstructed CopperLists buffered for the returned CuTwinReader. Defaults to 64.

Each TwinFrame contains one CopperList with its captured inputs and locally reconstructed outputs, plus sender identity and receive time. Increase this to absorb pauses in a UI or analysis reader; reduce it to retain fewer message payloads in memory. When full, the buffer replaces the oldest unread CopperList and the reader reports how many it missed. Recording and task replay continue independently of reader consumption. Network packets and recovery keyframes have separate receive/replay buffers; this capacity counts completed CopperLists.

Source

pub fn archive_only(self) -> Self

Record the native capture without starting task reconstruction.

Source

pub fn spawn(self) -> CuResult<(CuTwin<A>, CuTwinReader<A>)>

Auto Trait Implementations§

§

impl<A, R> !RefUnwindSafe for CuTwinBuilder<A, R>

§

impl<A, R> !UnwindSafe for CuTwinBuilder<A, R>

§

impl<A, R> Freeze for CuTwinBuilder<A, R>
where R: Freeze, PhantomData<fn() -> A>: Freeze,

§

impl<A, R> Send for CuTwinBuilder<A, R>
where R: Send, PhantomData<fn() -> A>: Send,

§

impl<A, R> Sync for CuTwinBuilder<A, R>
where R: Sync, PhantomData<fn() -> A>: Sync,

§

impl<A, R> Unpin for CuTwinBuilder<A, R>
where R: Unpin, PhantomData<fn() -> A>: Unpin,

§

impl<A, R> UnsafeUnpin for CuTwinBuilder<A, R>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSend for T
where T: Any + Send,

§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<A> Is for A
where A: Any,

§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. Read more
§

impl<T> PayloadDefaultHandlePolicyApply for T
where T: ?Sized,

§

fn apply_handle_content_policy(&self, _mode: HandleContent)

§

impl<T> PayloadDefaultLoggingPolicy for T
where T: ?Sized,

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.