Commit 40112e96 authored by Bryant's avatar Bryant

Merge branch 'no_prelude' into 'master'

Remove the prelude

See merge request susurrus/serialport-rs!82
parents 9eedfd39 f7ea3d50
......@@ -19,6 +19,8 @@ and this project adheres to http://semver.org/[Semantic Versioning].
==== Fixed
==== Removed
* Removed the `serialport::prelude` module. Types should be explicitly imported
or can be glob-imported from the root like `use serialport::*`.
=== [3.3.0] - 2019-06-12
==== Added
......
......@@ -34,9 +34,6 @@
// }
// ```
extern crate clap;
extern crate serialport;
use std::error::Error;
use std::io::{self, Read};
use std::sync::mpsc;
......@@ -44,7 +41,8 @@ use std::thread;
use std::time::Duration;
use clap::{App, AppSettings, Arg};
use serialport::prelude::*;
use serialport::{open_with_settings, ClearBuffer, SerialPortSettings};
fn main() {
let matches = App::new("Serialport Example - Clear Input Buffer")
......@@ -82,7 +80,7 @@ fn run(port_name: &str, baud_rate: &str) -> Result<(), Box<dyn Error>> {
.map_err(|_| format!("Invalid baud rate '{}' specified", baud_rate))?;
settings.baud_rate = rate.into();
let port = serialport::open_with_settings(&port_name, &settings)
let port = open_with_settings(&port_name, &settings)
.map_err(|ref e| format!("Port '{}' not available: {}", &port_name, e))?;
let chan_clear_buf = input_service();
......
......@@ -14,18 +14,15 @@
// 6. Press Ctrl+D (Unix) or Ctrl+Z (Win) to quit
//
#[macro_use]
extern crate clap;
extern crate serialport;
use std::error::Error;
use std::io::{self, Read};
use std::sync::mpsc;
use std::thread;
use std::time::Duration;
use clap::{App, AppSettings, Arg};
use serialport::prelude::*;
use clap::{value_t, App, AppSettings, Arg};
use serialport::{ClearBuffer, SerialPortSettings};
const DEFAULT_BLOCK_SIZE: &str = "128";
......
......@@ -11,13 +11,12 @@
//! To test this, have a physical or virtual loopback device connected as the
//! only port in the system.
extern crate serialport;
use serialport::{available_ports, open};
use std::io::Write;
use std::time::Duration;
use std::{io, thread};
use serialport::{available_ports, open};
fn main() {
// Open the first serialport available.
let mut serialport = open(&available_ports().expect("No serial port")[0].port_name)
......
......@@ -15,16 +15,15 @@
//! 3) With two ports physically connected to each other
//! `cargo run --example hardware_check /dev/ttyUSB0 /dev/ttyUSB1`
extern crate clap;
extern crate serialport;
use clap::{App, AppSettings, Arg};
use std::io::Write;
use std::str;
use std::time::Duration;
use serialport::prelude::*;
use clap::{App, AppSettings, Arg};
use serialport::{
ClearBuffer, DataBits, FlowControl, Parity, SerialPort, SerialPortSettings, StopBits,
};
fn main() {
let matches = App::new("Serialport Example - Hardware Check")
......
extern crate clap;
extern crate serialport;
use std::io::{self, Write};
use std::time::Duration;
use clap::{App, AppSettings, Arg};
use serialport::prelude::*;
use serialport::*;
fn main() {
let matches = App::new("Serialport Example - Heartbeat")
......
extern crate serialport;
use serialport::SerialPortType;
use serialport::{available_ports, SerialPortType};
fn main() {
match serialport::available_ports() {
match available_ports() {
Ok(ports) => {
match ports.len() {
0 => println!("No ports found."),
......
//! Pseudo terminal example.
extern crate serialport;
#[cfg(unix)]
fn main() {
use std::io::{Read, Write};
......
extern crate clap;
extern crate serialport;
use std::io::{self, Write};
use std::time::Duration;
use clap::{App, AppSettings, Arg};
use serialport::prelude::*;
use serialport::{open_with_settings, SerialPortSettings};
fn main() {
let matches = App::new("Serialport Example - Receive Data")
......@@ -36,7 +34,7 @@ fn main() {
::std::process::exit(1);
}
match serialport::open_with_settings(&port_name, &settings) {
match open_with_settings(&port_name, &settings) {
Ok(mut port) => {
let mut serial_buf: Vec<u8> = vec![0; 1000];
println!("Receiving data on {} at {} baud:", &port_name, &baud_rate);
......
......@@ -34,19 +34,6 @@ use std::io;
use std::path::Path;
use std::time::Duration;
/// A module that exports types that are useful to have in scope
///
/// It is intended to be glob imported:
///
/// ```
/// # #[allow(unused_imports)]
/// use serialport::prelude::*;
/// ```
pub mod prelude {
pub use crate::{ClearBuffer, DataBits, FlowControl, Parity, StopBits};
pub use crate::{SerialPort, SerialPortInfo, SerialPortSettings};
}
#[cfg(unix)]
mod posix;
#[cfg(unix)]
......@@ -542,7 +529,7 @@ pub fn open<T: AsRef<OsStr> + ?Sized>(port: &T) -> Result<Box<dyn SerialPort>> {
/// Opens the serial port specified by the device path with the given settings
///
/// ```
/// use serialport::prelude::*;
/// use serialport::*;
/// use std::time::Duration;
///
/// let s = SerialPortSettings {
......@@ -553,7 +540,7 @@ pub fn open<T: AsRef<OsStr> + ?Sized>(port: &T) -> Result<Box<dyn SerialPort>> {
/// stop_bits: StopBits::One,
/// timeout: Duration::from_millis(1),
/// };
/// serialport::open_with_settings("/dev/ttyUSB0", &s);
/// let p = open_with_settings("/dev/ttyUSB0", &s);
/// ```
pub fn open_with_settings<T: AsRef<OsStr> + ?Sized>(
port: &T,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment