[][src]Struct rpos_drv::Channel

pub struct Channel<P, T: ?Sized> { /* fields omitted */ }

Channel encode and decode message with protocol, and send and receive bytes via stream

Examples

This example deliberately fails to compile
let mut channel = Channel::new(
    RplidarProtocol::new(),
    serial_port
);
 
channel.write(&Message::new(1)).unwrap();

Methods

impl<P, T: ?Sized> Channel<P, T> where
    P: ProtocolDecoder + ProtocolEncoder,
    T: Read + Write
[src]

Create a new Channel to read and write messages

Example

This example deliberately fails to compile
let channel = Channel::new(
    RplidarProtocol::new(),
    serial_port
);

Create a new Channel with non-default ring buffer capacity

Example

This example deliberately fails to compile
let channel = Channel::with_read_buffer_size(
    RplidarProtocol::new(),
    serial_port,
    100000 as usize
);

Reset the channel status This function is usually used to reset protocol encoder and decoder when meet communication error

Example

This example deliberately fails to compile
match channel.invoke(&Message::new(1), Duration::from_secs(1)) {
    Ok(_) => {},
    Err(_) => { channel.reset(); }
}

Read message from channel

Example

This example deliberately fails to compile
if let Some(msg) = channel.read().unwrap() {
    println!("{:?}", msg);
}

Read message until timeout

Example

This example deliberately fails to compile
channel.read_until(Duration::from_secs(1));

Write message to channel

Example

This example deliberately fails to compile
channel.write(&Message::new(1)).unwrap();

Send a request to channel and wait for response

Example

This example deliberately fails to compile
let resp = channel.invoke(&Message::new(1), Duration::from_secs(1));

Trait Implementations

impl<P: Debug, T: Debug + ?Sized> Debug for Channel<P, T>
[src]

Auto Trait Implementations

impl<P, T: ?Sized> Send for Channel<P, T> where
    P: Send,
    T: Send

impl<P, T: ?Sized> Sync for Channel<P, T> where
    P: Sync,
    T: Sync

Blanket Implementations

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

impl<T> From for T
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.