summaryrefslogtreecommitdiffstats
path: root/vendor/env_logger/src/fmt/writer/termcolor/shim_impl.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:25 +0000
commit5363f350887b1e5b5dd21a86f88c8af9d7fea6da (patch)
tree35ca005eb6e0e9a1ba3bb5dbc033209ad445dc17 /vendor/env_logger/src/fmt/writer/termcolor/shim_impl.rs
parentAdding debian version 1.66.0+dfsg1-1. (diff)
downloadrustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.tar.xz
rustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.zip
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/env_logger/src/fmt/writer/termcolor/shim_impl.rs')
-rw-r--r--vendor/env_logger/src/fmt/writer/termcolor/shim_impl.rs73
1 files changed, 0 insertions, 73 deletions
diff --git a/vendor/env_logger/src/fmt/writer/termcolor/shim_impl.rs b/vendor/env_logger/src/fmt/writer/termcolor/shim_impl.rs
deleted file mode 100644
index bfc31d087..000000000
--- a/vendor/env_logger/src/fmt/writer/termcolor/shim_impl.rs
+++ /dev/null
@@ -1,73 +0,0 @@
-use std::{io, sync::Mutex};
-
-use crate::fmt::{WritableTarget, WriteStyle};
-
-pub(in crate::fmt::writer) mod glob {}
-
-pub(in crate::fmt::writer) struct BufferWriter {
- target: WritableTarget,
-}
-
-pub(in crate::fmt) struct Buffer(Vec<u8>);
-
-impl BufferWriter {
- pub(in crate::fmt::writer) fn stderr(_is_test: bool, _write_style: WriteStyle) -> Self {
- BufferWriter {
- target: WritableTarget::Stderr,
- }
- }
-
- pub(in crate::fmt::writer) fn stdout(_is_test: bool, _write_style: WriteStyle) -> Self {
- BufferWriter {
- target: WritableTarget::Stdout,
- }
- }
-
- pub(in crate::fmt::writer) fn pipe(
- _is_test: bool,
- _write_style: WriteStyle,
- pipe: Box<Mutex<dyn io::Write + Send + 'static>>,
- ) -> Self {
- BufferWriter {
- target: WritableTarget::Pipe(pipe),
- }
- }
-
- pub(in crate::fmt::writer) fn buffer(&self) -> Buffer {
- Buffer(Vec::new())
- }
-
- pub(in crate::fmt::writer) fn print(&self, buf: &Buffer) -> io::Result<()> {
- // This impl uses the `eprint` and `print` macros
- // instead of using the streams directly.
- // This is so their output can be captured by `cargo test`.
- match &self.target {
- // Safety: If the target type is `Pipe`, `target_pipe` will always be non-empty.
- WritableTarget::Pipe(pipe) => pipe.lock().unwrap().write_all(&buf.0)?,
- WritableTarget::Stdout => print!("{}", String::from_utf8_lossy(&buf.0)),
- WritableTarget::Stderr => eprint!("{}", String::from_utf8_lossy(&buf.0)),
- }
-
- Ok(())
- }
-}
-
-impl Buffer {
- pub(in crate::fmt) fn clear(&mut self) {
- self.0.clear();
- }
-
- pub(in crate::fmt) fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
- self.0.extend(buf);
- Ok(buf.len())
- }
-
- pub(in crate::fmt) fn flush(&mut self) -> io::Result<()> {
- Ok(())
- }
-
- #[cfg(test)]
- pub(in crate::fmt) fn bytes(&self) -> &[u8] {
- &self.0
- }
-}