serial 0.0.2

Rust library for accessing serial ports.


Platform: Cargo

Language: Rust

License: MIT

View on registry:


This crate provides Rust programs with access to serial ports. Serials ports are defined as traits to support extension through custom serial port implementations. The goals of the serial crate are to support all platforms supported by Rust. Currently, only Unix TTY devices are supported.


Add serial as a dependency in Cargo.toml:

serial = "0.0.2"

Import the serial crate and everything from the serial::prelude module. The serial::prelude module contains traits that are useful to have in scope. All the traits in prelude begin with Serial to avoid name conflicts with other crates. Having the traits in scope avoids compiler errors when using serial ports.

For now, you must open a serial port using a system-specific method. Once you've opened a serial port, you can interact with it using the SerialPort and SerialPortExt traits. By depending on the traits, your code will support future implementations of serial ports, including custom implementations such as those for embedded systems.

extern crate serial;
use std::io;
use std::path::Path;
// import useful traits
use serial::prelude::*;
fn main() {
 // opening port is system-specific
 let mut port = serial::posix::TTYPort::open(&Path::new("/dev/ttyUSB0")).unwrap();
 do_something(&mut port).unwrap();
// use SerialPort trait to program generically
fn do_something<T: SerialPort>(port: &mut T) -> io::Result<()> {
 try!(port.configure(|settings| {
 // read and write to port using Read and Write traits


Copyright © 2015 David Cuddeback

Distributed under the MIT License.

веселые картинки развлекательные гифки интресные факты смешные видео смешные истории из соцсетей


GitHub Repository

dcuddeback/serial-rs dcuddeback/serial-rs

Rust library for interacting with serial ports.

Language: Rust

Created: March 29, 2015 03:56

Last updated: March 30, 2015 03:14

Last pushed: March 29, 2015 19:56

Size: 0 Bytes

Stars: 0

Forks: 0

Watchers: 1

Open issues: 0

Top Contributors

David Cuddeback


  • 0.0.2 - March 29, 2015 19:56
  • 0.0.1 - March 29, 2015 03:56

Related Projects

dsfmt-rs 0.1.1
Rust port of the dSFMT random number generator.
Cargo - Rust - Other - Updated about 1 month ago - 3 stars
twitter-api 0.0.8
Unofficial Rust library for the Twitter API.
Cargo - Rust - MIT - Updated 3 days ago - 3 stars
xml-rs 0.1.22
An XML library in pure Rust
Cargo - Rust - MIT - Updated 7 days ago - 34 stars
math3d 0.0.1
A simple rust library for computer-graphics matrix calculations.
Cargo - Rust - MIT - Published 2 months ago - 2 stars
termios 0.0.3
Safe bindings for the termios library.
Cargo - Rust - MIT - Updated 3 days ago - 1 stars
веселые картинки развлекательные гифки интресные факты смешные видео смешные истории из соцсетей