[][src]Struct saberrs::SabertoothPortShared

pub struct SabertoothPortShared { /* fields omitted */ }

Clonable variant of SabertoothPort.

It is more flexible, for example it allows to mix several protocols (PlainText and PacketSerial) with the same port. However in most cases SabertoothPort is enough and recommended.

The downside of SabertoothPortShared, besides possible performance loss, is that it is not Send.

Example

use std::time::Duration;
use saberrs::{Result, SabertoothSerial, SabertoothPortShared};
use saberrs::sabertooth2x32::{PacketSerial, PacketType, PlainText, Sabertooth2x32};


let mut dev = SabertoothPortShared::new("/dev/ttyS2")?;

// The following interfaces will all communicate using the same port, but
// using different protocols.
let mut sabertext = PlainText::from(&dev);
let mut saberchecksum = PacketSerial::from(&dev).with_packet_type(PacketType::Checksum);
let mut sabercrc = PacketSerial::from(&dev).with_packet_type(PacketType::CRC);

Requires the "serialport" feature (enabled by default).

Implementations

impl SabertoothPortShared[src]

pub fn new(port: &str) -> Result<SabertoothPortShared>[src]

Create a new SabertoothPortShared with a default configuration

Trait Implementations

impl Clone for SabertoothPortShared[src]

impl Debug for SabertoothPortShared[src]

impl Read for SabertoothPortShared[src]

impl SabertoothSerial for SabertoothPortShared[src]

impl Write for SabertoothPortShared[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.