From 211ee1521d48c3180d6c3539cb1a262b49aa2b2a Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 3 Nov 2021 14:14:30 +0000 Subject: [PATCH] acpi_tables: aml: Add Aml trait implementation for vector appending As an optimisation to avoid allocating byte vectors add a trait method that will append to an existing vector. Further to support the transition add a default implementation of Aml::to_aml_bytes() that uses the newly added Aml::append_aml_bytes() Signed-off-by: Rob Bradford --- acpi_tables/src/aml.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/acpi_tables/src/aml.rs b/acpi_tables/src/aml.rs index 7f30568db..c6e40c4b8 100644 --- a/acpi_tables/src/aml.rs +++ b/acpi_tables/src/aml.rs @@ -6,7 +6,15 @@ use std::marker::PhantomData; pub trait Aml { - fn to_aml_bytes(&self) -> Vec; + fn append_aml_bytes(&self, _v: &mut Vec) { + unimplemented!() + } + + fn to_aml_bytes(&self) -> Vec { + let mut v = Vec::new(); + self.append_aml_bytes(&mut v); + v + } } pub const ZERO: Zero = Zero {};