Struct StdIoWrite
struct StdIoWrite<W>(2116)
An adapter for using std::io::Write implementations with fmt::Write.
This is useful when one wants to format a datetime or span directly
to something with a std::io::Write trait implementation but not a
fmt::Write implementation.
Example
use std::{fs::File, io::{BufWriter, Write}, path::Path};
use jiff::{civil::date, fmt::{StdIoWrite, temporal::DateTimePrinter}};
let zdt = date(2024, 6, 15).at(7, 0, 0, 0).in_tz("America/New_York")?;
let path = Path::new("/tmp/output");
let mut file = BufWriter::new(File::create(path)?);
DateTimePrinter::new().print_zoned(&zdt, StdIoWrite(&mut file)).unwrap();
file.flush()?;
assert_eq!(
std::fs::read_to_string(path)?,
"2024-06-15T07:00:00-04:00[America/New_York]",
);
# Ok::<(), Box<dyn std::error::Error>>(())
Implementations
impl<T> Any for StdIoWrite<W>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for StdIoWrite<W>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for StdIoWrite<W>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for StdIoWrite<W>
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for StdIoWrite<W>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for StdIoWrite<W>
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, U> Into for StdIoWrite<W>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for StdIoWrite<W>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for StdIoWrite<W>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>
impl<W> Freeze for StdIoWrite<W>
impl<W> RefUnwindSafe for StdIoWrite<W>
impl<W> Send for StdIoWrite<W>
impl<W> Sync for StdIoWrite<W>
impl<W> Unpin for StdIoWrite<W>
impl<W> UnwindSafe for StdIoWrite<W>
impl<W: $crate::clone::Clone> Clone for StdIoWrite<W>
fn clone(self: &Self) -> StdIoWrite<W>
impl<W: $crate::fmt::Debug> Debug for StdIoWrite<W>
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<'_>) -> $crate::fmt::Result
impl<W: std::io::Write> Write for StdIoWrite<W>
fn write_str(self: &mut Self, string: &str) -> Result<(), Error>