#![warn(missing_docs)]

//! A zero-copy fixed-width file format reader and writer implementation.
//!
//! # Reading records
//!
//! ```
//! use fwf::{Alignment, FwReader, FwReaderField, FwReaderSchema, RecordSeparator};
//!
//! let schema = FwReaderSchema::builder(7)
//!     .field(FwReaderField::builder(0..5).build())
//!     .field(FwReaderField::builder(5..7).build())
//!     .separator(RecordSeparator::Lf)
//!     .build()
//!     .unwrap();
//!
//! let data = b"Alice30\nBob  25\n";
//! let mut reader = FwReader::options(schema).from_reader(data.as_slice());
//!
//! while let Some(record) = reader.read_byte_record().unwrap() {
//!     let name = &record[0];
//!     let age = &record[1];
//!     println!("{}: {}", String::from_utf8_lossy(name), String::from_utf8_lossy(age));
//! }
//!
//! assert_eq!(reader.record_number(), 2);
//! ```
//!
//! # Writing records
//!
//! ```
//! use fwf::{
//!     Alignment, FwWriter, FwWriterField, FwWriterSchema, RecordSeparator,
//!     TruncationPolicy,
//! };
//!
//! let schema = FwWriterSchema::builder()
//!     .field(FwWriterField::builder(10).build())
//!     .field(FwWriterField::builder(1).padding(b'|').build())
//!     .field(
//!         FwWriterField::builder(3)
//!             .alignment(Alignment::Right)
//!             .padding(b'0')
//!             .build(),
//!     )
//!     .separator(RecordSeparator::Lf)
//!     .truncation(TruncationPolicy::Right)
//!     .build();
//!
//! let mut buf = Vec::new();
//! let mut writer = FwWriter::options(schema).from_writer(&mut buf);
//!
//! writer.write_byte_record(&[b"Name", b"|", b"Age"]).unwrap();
//! writer.write_byte_record(&[b"Alice", b"", b"30"]).unwrap();
//! writer.write_byte_record(&[b"Bob", b"", b"7"]).unwrap();
//!
//! drop(writer);
//! assert_eq!(buf, b"Name      |Age\nAlice     |030\nBob       |007\n");
//! ```

mod alignment;
#[cfg(feature = "tokio")]
mod async_fw_reader;
#[cfg(feature = "tokio")]
mod async_fw_writer;
mod byte_record;
mod byte_record_iterator;
mod fw_error;
mod fw_reader;
mod fw_reader_field;
mod fw_reader_options;
mod fw_reader_schema;
mod fw_reader_state;
mod fw_writer;
mod fw_writer_field;
mod fw_writer_options;
mod fw_writer_schema;
mod fw_writer_state;
mod record_separator;
#[cfg(feature = "encoding_rs")]
mod string_record;
#[cfg(feature = "encoding_rs")]
mod string_record_iterator;
mod truncation_policy;

pub use alignment::Alignment;
#[cfg(feature = "tokio")]
pub use async_fw_reader::AsyncFwReader;
#[cfg(feature = "tokio")]
pub use async_fw_writer::AsyncFwWriter;
pub use byte_record::ByteRecord;
pub use byte_record_iterator::ByteRecordIterator;
pub use fw_error::{FwfError, Result};
pub use fw_reader::FwReader;
pub use fw_reader_field::{FwReaderField, FwReaderFieldBuilder};
pub use fw_reader_options::FwReaderOptions;
pub use fw_reader_schema::{FwReaderSchema, FwReaderSchemaBuilder};
pub use fw_writer::FwWriter;
pub use fw_writer_field::{FwWriterField, FwWriterFieldBuilder};
pub use fw_writer_options::FwWriterOptions;
pub use fw_writer_schema::{FwWriterSchema, FwWriterSchemaBuilder};
pub use record_separator::RecordSeparator;
pub use truncation_policy::TruncationPolicy;

#[cfg(feature = "encoding_rs")]
pub use string_record::StringRecord;
#[cfg(feature = "encoding_rs")]
pub use string_record_iterator::StringRecordIterator;
