1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//! # Basic MAVLink I/O
//!
//! This module includes basic MAVLink I/O utils for reading and writing frames
//! ([`MavLinkFrame`](crate::Frame)).
//!
//! # Targets
//!
//! For `std` environments [`mavio`](crate) uses
//! [`std::io::Read`](https://doc.rust-lang.org/std/io/trait.Read.html)
//! and [`std::io::Write`](https://doc.rust-lang.org/std/io/trait.Write.html) reader and writer.
//!
//! For `no_std` [`mavio`](crate) uses custom `Read` and `Write` traits:
//!
//! ```rust
//! use mavio::error::Result;
//!
//! trait Read {
//!     fn read(&mut self, buf: &mut [u8]) -> Result<usize>;
//!     fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>;
//! }
//!
//! trait Write {
//!     fn write(&mut self, buf: &[u8]) -> Result<usize>;
//!     fn write_all(&mut self, buf: &[u8]) -> Result<()>;
//! }
//! ```
//!
//! In addition, the following `IoError` error is defined for `no_std`:
//!
//! ```rust
//! #[derive(Clone, Debug)]
//! pub enum IoError {
//!     /// Operation was interrupted.
//!     ///
//!     /// In most cases this means that operation can be retried.
//!     Interrupted,
//!     /// Invalid data received.
//!     InvalidData,
//!     /// This operation is unsupported.
//!     Unsupported,
//!     /// Unexpected end-of-file.
//!     ///
//!     /// In most cases this means that smaller amount of bytes are available.
//!     UnexpectedEof,
//!     /// Other error.
//!     Other(String),
//! }
//! ```
//!
//! This error will be wrapped with `no_std` version of [`Error`](crate::error::Error).

#[cfg(not(feature = "std"))]
pub(crate) mod no_std;
#[cfg(not(feature = "std"))]
pub use no_std::{Read, Write};
#[cfg(feature = "std")]
#[doc(hidden)]
pub use std::io::{Read, Write};

pub(crate) mod receiver;
pub use receiver::Receiver;

pub(crate) mod sender;
pub use sender::Sender;

#[cfg(feature = "async")]
mod async_receiver;
#[cfg(feature = "async")]
pub use async_receiver::AsyncReceiver;

#[cfg(feature = "async")]
mod async_sender;
#[cfg(feature = "async")]
pub use async_sender::AsyncSender;