pub struct FrameAdapter { /* private fields */ }Expand description
Converts a point buffer (frame) into a continuous stream.
The adapter cycles through the frame’s points, producing exactly
req.n_points on each next_chunk() call.
§Update semantics
update()sets the pending frame (latest-wins if called multiple times)- When the current frame ends, any pending frame becomes current immediately (even mid-chunk), ensuring clean frame-to-frame transitions
§Example
ⓘ
let mut adapter = FrameAdapter::new();
adapter.update(Frame::new(circle_points));
loop {
let req = stream.next_request()?;
let points = adapter.next_chunk(&req);
stream.write(&req, &points)?;
}Implementations§
Source§impl FrameAdapter
impl FrameAdapter
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new adapter with an empty frame.
Call update() to set the initial frame before streaming.
Sourcepub fn update(&mut self, frame: Frame)
pub fn update(&mut self, frame: Frame)
Sets the pending frame.
The frame becomes current when the current frame ends (all points output). If called multiple times before a swap, only the most recent frame is kept (latest-wins).
Sourcepub fn next_chunk(&mut self, req: &ChunkRequest) -> Vec<LaserPoint>
pub fn next_chunk(&mut self, req: &ChunkRequest) -> Vec<LaserPoint>
Produces exactly req.n_points points.
Cycles through the current frame. When the frame ends and a pending frame is available, switches immediately (even mid-chunk).
Returns a thread-safe handle for updating frames from another thread.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FrameAdapter
impl RefUnwindSafe for FrameAdapter
impl Send for FrameAdapter
impl Sync for FrameAdapter
impl Unpin for FrameAdapter
impl UnwindSafe for FrameAdapter
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