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 <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2021-11-03 14:14:30 +00:00
parent d0c3342c97
commit 211ee1521d

View File

@ -6,7 +6,15 @@
use std::marker::PhantomData;
pub trait Aml {
fn to_aml_bytes(&self) -> Vec<u8>;
fn append_aml_bytes(&self, _v: &mut Vec<u8>) {
unimplemented!()
}
fn to_aml_bytes(&self) -> Vec<u8> {
let mut v = Vec::new();
self.append_aml_bytes(&mut v);
v
}
}
pub const ZERO: Zero = Zero {};