pub struct BufferState {
pub total_size: u16,
pub free_space: u16,
pub threshold: u16,
pub last_update_time: u64,
}Expand description
Tracks the state of the LaserCube’s buffer.
Fields§
§total_size: u16Total buffer size.
free_space: u16Current free space in the buffer.
threshold: u16Threshold for deciding when to send more data.
last_update_time: u64Last time we received a buffer update (in milliseconds since start).
Implementations§
Source§impl BufferState
impl BufferState
pub const DEFAULT: Self
Sourcepub fn update_free_space(&mut self, free_space: u16, current_time: u64)
pub fn update_free_space(&mut self, free_space: u16, current_time: u64)
Update buffer free space from device response.
Sourcepub fn update_total_size(&mut self, total_size: u16)
pub fn update_total_size(&mut self, total_size: u16)
Update total buffer size from device response.
Sourcepub fn should_send(&self) -> bool
pub fn should_send(&self) -> bool
Check if we should send more data based on buffer free space.
Sourcepub fn estimate_current_free_space(
&self,
current_time: u64,
dac_rate: u32,
) -> u16
pub fn estimate_current_free_space( &self, current_time: u64, dac_rate: u32, ) -> u16
Estimate current free space based on time elapsed and DAC rate.
Trait Implementations§
Source§impl Clone for BufferState
impl Clone for BufferState
Source§fn clone(&self) -> BufferState
fn clone(&self) -> BufferState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BufferState
impl Debug for BufferState
Source§impl Default for BufferState
impl Default for BufferState
impl Copy for BufferState
Auto Trait Implementations§
impl Freeze for BufferState
impl RefUnwindSafe for BufferState
impl Send for BufferState
impl Sync for BufferState
impl Unpin for BufferState
impl UnwindSafe for BufferState
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