Struct ffx_writer::MachineWriter
source · pub struct MachineWriter<T> { /* private fields */ }
Expand description
Type-safe machine output implementation of crate::ToolIO
Implementations§
source§impl<T> MachineWriter<T>
impl<T> MachineWriter<T>
sourcepub fn new_buffers<'a, O, E>(
format: Option<Format>,
stdout: O,
stderr: E
) -> Self
pub fn new_buffers<'a, O, E>( format: Option<Format>, stdout: O, stderr: E ) -> Self
Create a new writer that doesn’t support machine output at all, with the given streams underlying it.
sourcepub fn new(format: Option<Format>) -> Self
pub fn new(format: Option<Format>) -> Self
Create a new Writer with the specified format.
Passing None for format implies no output via the machine function.
sourcepub fn new_test(format: Option<Format>, test_buffers: &TestBuffers) -> Self
pub fn new_test(format: Option<Format>, test_buffers: &TestBuffers) -> Self
Returns a writer backed by string buffers that can be extracted after the writer is done with
source§impl<T> MachineWriter<T>where
T: Serialize,
impl<T> MachineWriter<T>where
T: Serialize,
sourcepub fn machine_many<I: IntoIterator<Item = T>>(
&mut self,
output: I
) -> Result<(), Error>
pub fn machine_many<I: IntoIterator<Item = T>>( &mut self, output: I ) -> Result<(), Error>
Write the items from the iterable object to standard output.
This is a no-op if is_machine
returns false.
sourcepub fn machine(&mut self, output: &T) -> Result<(), Error>
pub fn machine(&mut self, output: &T) -> Result<(), Error>
Write the item to standard output.
This is a no-op if is_machine
returns false.
Trait Implementations§
source§impl<T> ToolIO for MachineWriter<T>where
T: Serialize,
impl<T> ToolIO for MachineWriter<T>where
T: Serialize,
§type OutputItem = T
type OutputItem = T
The type of object that is expected for the
Self::item
call (or
any machine output writing functions that may be added by an
implementation)source§fn is_machine_supported() -> bool
fn is_machine_supported() -> bool
Whether this can theoretically support machine output given the right configuration.
source§fn is_machine(&self) -> bool
fn is_machine(&self) -> bool
Returns true if the receiver was configured to output for machines.
source§fn item(&mut self, value: &T) -> Result<(), Error>where
T: Display,
fn item(&mut self, value: &T) -> Result<(), Error>where
T: Display,
Displays the item in whatever formatted style is most appropriate based
on is_machine and the underlying implementation
source§fn stderr(&mut self) -> &mut Box<dyn Write>
fn stderr(&mut self) -> &mut Box<dyn Write>
Returns an error stream that errors can be written to.
source§fn has_schema() -> bool
fn has_schema() -> bool
Is a schema of the output type available.
fn try_print_schema(&mut self) -> Result<(), Error>
source§impl<T> Write for MachineWriter<T>where
T: Serialize,
impl<T> Write for MachineWriter<T>where
T: Serialize,
source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Write a buffer into this writer, returning how many bytes were written. Read more
source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered
contents reach their destination. Read more
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector
)1.0.0 · source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this writer. Read more
source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
write_all_vectored
)Attempts to write multiple buffers into this writer. Read more
Auto Trait Implementations§
impl<T> !RefUnwindSafe for MachineWriter<T>
impl<T> !Send for MachineWriter<T>
impl<T> !Sync for MachineWriter<T>
impl<T> Unpin for MachineWriter<T>
impl<T> !UnwindSafe for MachineWriter<T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more