#[non_exhaustive]pub struct Frame {
pub offset: u64,
pub bytes: Vec<u8>,
}Expand description
One encoded mutation frame parked in the backlog.
use kevy_replicate::source::ReplicationSource;
let set = kevy_resp::Argv::from(vec![b"SET".to_vec(), b"k".to_vec(), b"v".to_vec()]);
let mut backlog = ReplicationSource::new(1 << 20);
backlog.push_mutation(&set);
let frame = backlog.frames_from(0).ok().and_then(|mut f| f.next()).expect("offset 0 is buffered");
let (decoded, used) = kevy_replicate::wire::decode_frame(&frame.bytes)?;
assert_eq!((decoded.offset, decoded.argv, used), (frame.offset, set, frame.bytes.len()));Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.offset: u64Monotonic offset the source assigned at push time.
use kevy_replicate::source::ReplicationSource;
let set = kevy_resp::Argv::from(vec![b"SET".to_vec(), b"k".to_vec(), b"v".to_vec()]);
let mut backlog = ReplicationSource::new(1 << 20);
let assigned = backlog.push_mutation(&set);
assert_eq!(backlog.frames_from(0)?.next().map(|f| f.offset), Some(assigned));bytes: Vec<u8>Wire-encoded frame bytes (envelope + offset + RESP argv).
use kevy_replicate::source::ReplicationSource;
let set = kevy_resp::Argv::from(vec![b"SET".to_vec(), b"k".to_vec(), b"v".to_vec()]);
let mut backlog = ReplicationSource::new(1 << 20);
backlog.push_mutation(&set);
let frame = backlog.frames_from(0)?.next().expect("one frame");
assert_eq!(frame.bytes, b"*2\r\n:0\r\n*3\r\n$3\r\nSET\r\n$1\r\nk\r\n$1\r\nv\r\n");Trait Implementations§
impl Eq for Frame
impl StructuralPartialEq for Frame
Auto Trait Implementations§
impl Freeze for Frame
impl RefUnwindSafe for Frame
impl Send for Frame
impl Sync for Frame
impl Unpin for Frame
impl UnsafeUnpin for Frame
impl UnwindSafe for Frame
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