Expand description
output file type
Tuple Fields
0: BufWriter<Box<dyn Write>>
1: String
Implementations
sourceimpl Outfile
impl Outfile
sourcepub fn new(f: BufWriter<Box<dyn Write>>, n: &str) -> Self
pub fn new(f: BufWriter<Box<dyn Write>>, n: &str) -> Self
create a new input file
Examples found in repository
src/util.rs (line 661)
≺ ≻
660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709
fn default() -> Self {
Self::new(io::BufWriter::new(Box::new(io::sink())), "")
}
}
impl fmt::Debug for Outfile {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Outfile : {}", self.1)
}
}
impl Deref for Outfile {
type Target = io::BufWriter<Box<dyn Write>>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl DerefMut for Outfile {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
impl AsRef<io::BufWriter<Box<dyn Write>>> for Outfile {
fn as_ref(&self) -> &io::BufWriter<Box<dyn Write>> {
&self.0
}
}
impl AsMut<io::BufWriter<Box<dyn Write>>> for Outfile {
fn as_mut(&mut self) -> &mut io::BufWriter<Box<dyn Write>> {
&mut self.0
}
}
/// Make an Outfile from a file name
pub fn get_writer(name: &str) -> Result<Outfile> {
let inner: Box<dyn Write> = {
if name == "-" {
Box::new(io::stdout())
} else if name == "--" {
Box::new(io::stderr())
} else {
Box::new(fs::OpenOptions::new().write(true).create(true).open(name)?)
}
};
Ok(Outfile::new(io::BufWriter::new(inner), name))
}
Methods from Deref<Target = BufWriter<Box<dyn Write>>>
1.0.0 · sourcepub fn get_ref(&self) -> &W
pub fn get_ref(&self) -> &W
Gets a reference to the underlying writer.
Examples
use std::io::BufWriter;
use std::net::TcpStream;
let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap());
// we can use reference just like buffer
let reference = buffer.get_ref();
1.0.0 · sourcepub fn get_mut(&mut self) -> &mut W
pub fn get_mut(&mut self) -> &mut W
Gets a mutable reference to the underlying writer.
It is inadvisable to directly write to the underlying writer.
Examples
use std::io::BufWriter;
use std::net::TcpStream;
let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap());
// we can use reference just like buffer
let reference = buffer.get_mut();
1.37.0 · sourcepub fn buffer(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn buffer(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Returns a reference to the internally buffered data.
Examples
use std::io::BufWriter;
use std::net::TcpStream;
let buf_writer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap());
// See how many bytes are currently buffered
let bytes_buffered = buf_writer.buffer().len();
1.46.0 · sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the number of bytes the internal buffer can hold without flushing.
Examples
use std::io::BufWriter;
use std::net::TcpStream;
let buf_writer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap());
// Check the capacity of the inner buffer
let capacity = buf_writer.capacity();
// Calculate how many bytes can be written without flushing
let without_flush = capacity - buf_writer.buffer().len();
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Outfile
impl !Send for Outfile
impl !Sync for Outfile
impl Unpin for Outfile
impl !UnwindSafe for Outfile
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more