From b2405efb0902200786c8186aff0858e775ee7adc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Mon, 25 Nov 2024 17:19:41 +0100 Subject: [PATCH] refactor(console): extract `Console::write` --- src/console.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/console.rs b/src/console.rs index cd84f2deb8..f2ab905105 100644 --- a/src/console.rs +++ b/src/console.rs @@ -6,6 +6,12 @@ use crate::arch; pub(crate) struct Console(()); +impl Console { + pub fn write(&mut self, buf: &[u8]) { + arch::output_message_buf(buf); + } +} + /// A collection of methods that are required to format /// a message to Hermit's console. impl fmt::Write for Console { @@ -13,15 +19,14 @@ impl fmt::Write for Console { #[inline] fn write_str(&mut self, s: &str) -> fmt::Result { if !s.is_empty() { - let buf = s.as_bytes(); - arch::output_message_buf(buf); + self.write(s.as_bytes()); } Ok(()) } } -static CONSOLE: InterruptTicketMutex = InterruptTicketMutex::new(Console(())); +pub(crate) static CONSOLE: InterruptTicketMutex = InterruptTicketMutex::new(Console(())); #[doc(hidden)] pub fn _print(args: fmt::Arguments<'_>) {