4 releases

0.1.3 May 11, 2023
0.1.2 May 10, 2023
0.1.1 May 3, 2023
0.1.0 May 1, 2023

#1781 in Parser implementations

MIT license

886 lines


This crate provides the basics for parsing and writing refer files.

It intends to follow the specification, but may be narrower in scope eventually.


Add this to your Cargo.toml file:

refer = "0.1.3"


Read a refer file from stdin, and print to stdout.

use refer::Reader;
use std::{io, error};

fn main() -> Result<(), Box<dyn error::Error>> {

    // construct a new reader
    let mut reader = Reader::new(io::stdin());

    // iterate over the records (borrowing them)
    for result in reader.records() {
        // records() returns a result
        let record = result?;
        // print the record line to stdout
        println!("{:?}", record);


There's also a refer::Writer struct for writing refer files. See the documentation for further information on this.


Thanks to BurntSushi/Andrew Gallant for his work on the csv crate, on which the API/codebase for this current work is designed.


~20K SLoC