pub enum XvcCommand {
GetInfo,
SetTck,
Shift,
}Expand description
Possible commands that are known to the XVC protocol.
Variants§
Implementations§
Source§impl XvcCommand
impl XvcCommand
Sourcepub fn parse(buf: &mut &[u8]) -> Result<XvcCommand, ParseErr>
pub fn parse(buf: &mut &[u8]) -> Result<XvcCommand, ParseErr>
Parse a command from a buffer.
§Example
use xvc_protocol::{XvcCommand};
let mut buf: &[u8] = b"getinfo:";
let command = XvcCommand::parse(&mut buf).expect("Parsing a large enough buffer should not fail");
assert_eq!(command, XvcCommand::GetInfo);
assert_eq!(buf.len(), 0);If the buffer is not large enough, ParseErr::Incomplete is returned.
This usually indicates to the caller to read more bytes into the buffer:
A buffer that is too large is permitted. After a successful parse the buffer is advanced past the consumed command bytes:
use xvc_protocol::XvcCommand;
let mut buf: &[u8] = b"settck:\x64";
let command = XvcCommand::parse(&mut buf).expect("Parsing a large enough buffer should not fail");
assert_eq!(command, XvcCommand::SetTck);
assert_eq!(buf.len(), 1);Trait Implementations§
Source§impl Clone for XvcCommand
impl Clone for XvcCommand
Source§fn clone(&self) -> XvcCommand
fn clone(&self) -> XvcCommand
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 XvcCommand
impl Debug for XvcCommand
Source§impl PartialEq for XvcCommand
impl PartialEq for XvcCommand
impl Eq for XvcCommand
impl StructuralPartialEq for XvcCommand
Auto Trait Implementations§
impl Freeze for XvcCommand
impl RefUnwindSafe for XvcCommand
impl Send for XvcCommand
impl Sync for XvcCommand
impl Unpin for XvcCommand
impl UnsafeUnpin for XvcCommand
impl UnwindSafe for XvcCommand
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