Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ features = [
cfg-if = "1.0.0"
scopeguard = "1.1"
serde = { version = "1.0", features = ["derive"], optional = true }
schemars = { package = "schemars", version = "0.8", features = ["derive"], optional = true }

[dev-dependencies]
assert_hex = "0.4.1"
Expand Down
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ impl From<Error> for io::Error {
/// Number of bits per character
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum DataBits {
/// 5 bits per character
Five,
Expand Down Expand Up @@ -199,6 +200,7 @@ impl TryFrom<u8> for DataBits {
/// transmitted.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum Parity {
/// No parity bit.
None,
Expand All @@ -225,6 +227,7 @@ impl fmt::Display for Parity {
/// Stop bits are transmitted after every character.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum StopBits {
/// One stop bit.
One,
Expand Down Expand Up @@ -266,6 +269,7 @@ impl TryFrom<u8> for StopBits {
/// Flow control modes
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum FlowControl {
/// No flow control.
None,
Expand Down Expand Up @@ -305,6 +309,7 @@ impl FromStr for FlowControl {
/// [`clear`]: trait.SerialPort.html#tymethod.clear
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum ClearBuffer {
/// Specify to clear data received but not read
Input,
Expand Down Expand Up @@ -798,6 +803,7 @@ impl fmt::Debug for dyn SerialPort {
/// Contains all possible USB information about a `SerialPort`
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct UsbPortInfo {
/// Vendor ID
pub vid: u16,
Expand All @@ -819,6 +825,7 @@ pub struct UsbPortInfo {
/// The physical type of a `SerialPort`
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum SerialPortType {
/// The serial port is connected via USB
UsbPort(UsbPortInfo),
Expand All @@ -833,6 +840,7 @@ pub enum SerialPortType {
/// A device-independent implementation of serial port information
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct SerialPortInfo {
/// The short name of the serial port
pub port_name: String,
Expand Down
Loading