Skip to main content

Writer

Struct Writer 

Source
pub struct Writer<'a, L> {
    pub writer: DeferredWriter<'a>,
    pub code: usize,
    /* private fields */
}

Fields§

§writer: DeferredWriter<'a>§code: usize

Implementations§

Source§

impl<'a, L> Writer<'a, L>
where L: Lit,

Source

pub fn new(writer: DeferredWriter<'a>) -> Self

Examples found in repository?
examples/aagtoaig.rs (line 33)
16fn main_err() -> Result<(), Error<u32>> {
17    let stdin = std::io::stdin();
18    let stdout = std::io::stdout();
19
20    let aag_reader = ascii::Parser::<u32>::from_read(stdin.lock(), ascii::Config::default())?;
21
22    let aag = aag_reader.parse()?;
23
24    let (aig, _) = Renumber::renumber_aig(
25        RenumberConfig::default()
26            .trim(true)
27            .structural_hash(true)
28            .const_fold(true),
29        &aag,
30    )?;
31
32    let aig_writer = DeferredWriter::from_write(stdout.lock());
33    let mut aag_writer = binary::Writer::<u32>::new(aig_writer);
34
35    aag_writer.write_ordered_aig(&aig);
36
37    aag_writer.flush()?;
38    Ok(())
39}
Source

pub fn write_header(&mut self, header: &Header)

Source

pub fn write_lit(&mut self, lit: L)

Source

pub fn write_latch(&mut self, latch: OrderedLatch<L>)

Source

pub fn write_count(&mut self, count: usize)

Source

pub fn write_and_gate(&mut self, and_gate: OrderedAndGate<L>)

Source

pub fn write_symbol(&mut self, symbol: &Symbol<'_>)

Source

pub fn write_comment(&mut self, comment: &str)

Source

pub fn write_ordered_aig(&mut self, aig: &OrderedAig<L>)

Examples found in repository?
examples/aagtoaig.rs (line 35)
16fn main_err() -> Result<(), Error<u32>> {
17    let stdin = std::io::stdin();
18    let stdout = std::io::stdout();
19
20    let aag_reader = ascii::Parser::<u32>::from_read(stdin.lock(), ascii::Config::default())?;
21
22    let aag = aag_reader.parse()?;
23
24    let (aig, _) = Renumber::renumber_aig(
25        RenumberConfig::default()
26            .trim(true)
27            .structural_hash(true)
28            .const_fold(true),
29        &aag,
30    )?;
31
32    let aig_writer = DeferredWriter::from_write(stdout.lock());
33    let mut aag_writer = binary::Writer::<u32>::new(aig_writer);
34
35    aag_writer.write_ordered_aig(&aig);
36
37    aag_writer.flush()?;
38    Ok(())
39}

Methods from Deref<Target = DeferredWriter<'a>>§

Source

pub fn flush_defer_err(&mut self)

Flush the buffered data to the underlying Write instance, deferring IO errors.

Source

pub fn write_all_defer_err(&mut self, buf: &[u8])

Write a slice of bytes, deferring IO errors.

Both, write and write_all directly call this method. Unlike them, this does not return a #[must_use] value, making it clear that this cannot return an error.

Source

pub fn buf_write_ptr(&mut self, len: usize) -> *mut u8

Returns a pointer to the current write pointer within the internal buffer if sufficient space is available.

If only fewer than len bytes are available, this returns a null pointer.

Can be used in conjunction with advance_unchecked to construct output data directly within the output buffer, potentially avoiding a redundant copy.

Source

pub unsafe fn advance_unchecked(&mut self, len: usize)

Advances the write pointer within the internal buffer.

§Safety

This assumes that a) there is sufficient space left in the buffer and b) that the bytes the pointer is advanced over were initialized prior to calling this (via buf_write_ptr).

If either assumption does not hold calling this results in undefined behavior.

Source

pub fn check_io_error(&mut self) -> Result<(), Error>

Returns an encountered IO errors as Err(io_err).

This resets the stored IO error and returns Ok(()) if no IO error is stored.

Trait Implementations§

Source§

impl<'a, L> Deref for Writer<'a, L>

Source§

type Target = DeferredWriter<'a>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'a, L> DerefMut for Writer<'a, L>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<'a, L> !RefUnwindSafe for Writer<'a, L>

§

impl<'a, L> !Send for Writer<'a, L>

§

impl<'a, L> !Sync for Writer<'a, L>

§

impl<'a, L> !UnwindSafe for Writer<'a, L>

§

impl<'a, L> Freeze for Writer<'a, L>

§

impl<'a, L> Unpin for Writer<'a, L>
where L: Unpin,

§

impl<'a, L> UnsafeUnpin for Writer<'a, L>

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.