From 586f2b77e73c36287750a1a55b365d001cd793a8 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 3 May 2021 14:01:12 +0100 Subject: [PATCH] apitest: Allow reading OtterOutput to a string Signed-off-by: Ian Jackson --- apitest/apitest.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apitest/apitest.rs b/apitest/apitest.rs index 4a277c63..5bb53ad0 100644 --- a/apitest/apitest.rs +++ b/apitest/apitest.rs @@ -654,6 +654,15 @@ impl From for String { s } } +impl From<&mut OtterOutput> for String { + fn from(oo: &mut OtterOutput) -> String { + let mut s = String::new(); + let o = oo.output.as_mut().unwrap(); + o.rewind().unwrap(); + o.read_to_string(&mut s).unwrap(); + s + } +} impl Drop for OtterOutput { fn drop(&mut self) { if let Some(mut o) = self.output.take() { -- 2.30.2