pub struct MessageBuilder { /* private fields */ }
Expand description
Builder of Message (standard) instances.
Provided methods fill the message with corresponding bits, then MessageBuilder::finalize() produces the final Message.
Please note that currently no logical validation is done. For example the “sense” bit can be overwritten, and thus invalidate previous method call.
§Example
let msg = MessageBuilder::new(10)
.camera_on()
.focus_far()
.direction(Direction::DOWN)
.tilt(Speed::Range(0.5))
.finalize()?;
assert_eq!(&[0xFF, 0x0A, 0x88, 0x90, 0x00, 0x20, 0x42], msg.as_ref());
Implementations§
Source§impl MessageBuilder
impl MessageBuilder
pub fn new(address: u8) -> MessageBuilder
pub fn direction(&mut self, direction: Direction) -> &mut Self
pub fn down(&mut self) -> &mut Self
pub fn up(&mut self) -> &mut Self
pub fn left(&mut self) -> &mut Self
pub fn right(&mut self) -> &mut Self
pub fn pan(&mut self, speed: Speed) -> &mut Self
pub fn tilt(&mut self, speed: Speed) -> &mut Self
pub fn stop(&mut self) -> &mut Self
pub fn zoom_in(&mut self) -> &mut Self
pub fn zoom_out(&mut self) -> &mut Self
pub fn camera_on(&mut self) -> &mut Self
pub fn camera_off(&mut self) -> &mut Self
pub fn auto_scan(&mut self) -> &mut Self
pub fn manual_scan(&mut self) -> &mut Self
pub fn close_iris(&mut self) -> &mut Self
pub fn open_iris(&mut self) -> &mut Self
pub fn focus_far(&mut self) -> &mut Self
pub fn focus_near(&mut self) -> &mut Self
pub fn finalize(self) -> Result<Message>
Trait Implementations§
Source§impl Clone for MessageBuilder
impl Clone for MessageBuilder
Source§fn clone(&self) -> MessageBuilder
fn clone(&self) -> MessageBuilder
Returns a copy 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 MessageBuilder
impl Debug for MessageBuilder
Source§impl From<MessageBuilder> for Message
impl From<MessageBuilder> for Message
Source§fn from(draft: MessageBuilder) -> Self
fn from(draft: MessageBuilder) -> Self
Converts to this type from the input type.
Source§impl PartialEq for MessageBuilder
impl PartialEq for MessageBuilder
impl Copy for MessageBuilder
impl StructuralPartialEq for MessageBuilder
Auto Trait Implementations§
impl Freeze for MessageBuilder
impl RefUnwindSafe for MessageBuilder
impl Send for MessageBuilder
impl Sync for MessageBuilder
impl Unpin for MessageBuilder
impl UnwindSafe for MessageBuilder
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