[][src]Struct fixed_width::Writer

pub struct Writer<W: Write> { /* fields omitted */ }

A fixed width data writer. It writes data provided in iterators to any type that implements io::Write.

Example

Writing a Vec<String> to a file:

extern crate fixed_width;
use std::io::Write;
use fixed_width::Writer;

let data = vec![
    "1234".to_string(),
    "5678".to_string(),
];

let mut wrtr = Writer::from_memory();
wrtr.write_iter(data.iter());
wrtr.flush();

Methods

impl<W> Writer<W> where
    W: Write
[src]

pub fn from_writer(wrtr: W) -> Self[src]

Creates a new writer from any type that implements io::Write

pub fn from_buffer(buf: BufWriter<W>) -> Self[src]

Creates a new writer from a io::BufWriter that wraps a type that implements io::Write

pub fn write_serialized<T: FixedWidth + Serialize>(
    &mut self,
    records: impl Iterator<Item = T>
) -> Result<()>
[src]

Writes the given iterator of FixedWidth + Serialize types to the underlying writer, optionally inserting linebreaks if specified.

pub fn write_iter<T: AsByteSlice>(
    &mut self,
    records: impl Iterator<Item = T>
) -> Result<()>
[src]

Writes the given iterator of types that implement AsByteSlice to the underlying writer, optionally inserting linebreaks if specified.

pub fn write_linebreak(&mut self) -> Result<()>[src]

Writes the linebreak specified to the underlying writer. Does nothing if there is no linebreak.

pub fn linebreak(self, linebreak: LineBreak) -> Self[src]

Sets the linebreak desired for this data. Defaults to LineBreak::None.

impl Writer<Vec<u8>>[src]

pub fn from_memory() -> Self[src]

Creates a new writer in memory from a Vec<u8>.

Trait Implementations

impl Into<Vec<u8>> for Writer<Vec<u8>>[src]

fn into(self) -> Vec<u8>[src]

Converts the writer into a Vec<u8>, but panics if unable to flush to the underlying writer.

impl Into<String> for Writer<Vec<u8>>[src]

fn into(self) -> String[src]

Converts the writer into a String, but panics if unable to flush to the underlying

impl<W> Write for Writer<W> where
    W: Write
[src]

fn write(&mut self, buf: &[u8]) -> Result<usize>[src]

Writes a buffer into the underlying writer.

fn flush(&mut self) -> Result<()>[src]

flushes the underlying writer.

fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0
[src]

Attempts to write an entire buffer into this writer. Read more

fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0
[src]

Writes a formatted string into this writer, returning any error encountered. Read more

fn by_ref(&mut self) -> &mut Self
1.0.0
[src]

Creates a "by reference" adaptor for this instance of Write. Read more

Auto Trait Implementations

impl<W> Send for Writer<W> where
    W: Send

impl<W> Sync for Writer<W> where
    W: Sync

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.