Struct MessageBuilder

Source
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

Source

pub fn new(address: u8) -> MessageBuilder

Source

pub fn direction(&mut self, direction: Direction) -> &mut Self

Source

pub fn down(&mut self) -> &mut Self

Source

pub fn up(&mut self) -> &mut Self

Source

pub fn left(&mut self) -> &mut Self

Source

pub fn right(&mut self) -> &mut Self

Source

pub fn pan(&mut self, speed: Speed) -> &mut Self

Source

pub fn tilt(&mut self, speed: Speed) -> &mut Self

Source

pub fn stop(&mut self) -> &mut Self

Source

pub fn zoom_in(&mut self) -> &mut Self

Source

pub fn zoom_out(&mut self) -> &mut Self

Source

pub fn camera_on(&mut self) -> &mut Self

Source

pub fn camera_off(&mut self) -> &mut Self

Source

pub fn auto_scan(&mut self) -> &mut Self

Source

pub fn manual_scan(&mut self) -> &mut Self

Source

pub fn close_iris(&mut self) -> &mut Self

Source

pub fn open_iris(&mut self) -> &mut Self

Source

pub fn focus_far(&mut self) -> &mut Self

Source

pub fn focus_near(&mut self) -> &mut Self

Source

pub fn finalize(self) -> Result<Message>

Trait Implementations§

Source§

impl Clone for MessageBuilder

Source§

fn clone(&self) -> MessageBuilder

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MessageBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<MessageBuilder> for Message

Source§

fn from(draft: MessageBuilder) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for MessageBuilder

Source§

fn eq(&self, other: &MessageBuilder) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for MessageBuilder

Source§

impl StructuralPartialEq for MessageBuilder

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.