Skip to main content

GenericStreamEncoder

Struct GenericStreamEncoder 

Source
pub struct GenericStreamEncoder<W: Write> { /* private fields */ }
Expand description

GenericStreamEncoder writes GCF tabular output incrementally as rows arrive. Zero buffering: each row is written immediately. A trailer summary is emitted on close() with the final counts.

Thread-safe via internal Mutex.

§Example

use gcf::GenericStreamEncoder;
use gcf::stream_generic::GcfValue;

let buf = Vec::new();
let enc = GenericStreamEncoder::new(buf);
enc.begin_array("employees", &["id", "name", "department", "salary"]);
enc.write_row(&[1.into(), "Alice".into(), "Engineering".into(), 95000.into()]);
enc.end_array();
enc.close().unwrap();

Implementations§

Source§

impl<W: Write> GenericStreamEncoder<W>

Source

pub fn new(w: W) -> Self

Create a new streaming encoder for tabular/generic data.

Source

pub fn begin_array(&self, name: &str, fields: &[&str])

Start a tabular array section with deferred count [?].

Source

pub fn write_row(&self, values: &[GcfValue])

Emit a single pipe-separated row immediately.

Source

pub fn end_array(&self)

Close the current array section and record its count.

Source

pub fn write_kv(&self, key: &str, value: &GcfValue)

Emit a key=value line immediately.

Source

pub fn write_section(&self, name: &str)

Start a nested object section (## key).

Source

pub fn write_inline_array(&self, name: &str, values: &[GcfValue])

Emit a primitive array inline: name[N]: val1,val2,val3

Source

pub fn close(&self) -> Result<()>

Emit the ## _summary trailer with final counts.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.