From 395929f1d450b79f1dc0f686557832534aceb083 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 3 Nov 2021 14:29:05 +0000 Subject: [PATCH] acpi_tables: aml: Implement Aml::append_aml_bytes() for number types Including Byte, Word, DWord and QWord. Signed-off-by: Rob Bradford --- acpi_tables/src/aml.rs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/acpi_tables/src/aml.rs b/acpi_tables/src/aml.rs index 6076f444d..cf93fb30b 100644 --- a/acpi_tables/src/aml.rs +++ b/acpi_tables/src/aml.rs @@ -98,40 +98,36 @@ impl From<&str> for Path { pub type Byte = u8; impl Aml for Byte { - fn to_aml_bytes(&self) -> Vec { - let mut bytes = vec![0x0a]; /* BytePrefix */ + fn append_aml_bytes(&self, bytes: &mut Vec) { + bytes.push(0x0a); /* BytePrefix */ bytes.push(*self); - bytes } } pub type Word = u16; impl Aml for Word { - fn to_aml_bytes(&self) -> Vec { - let mut bytes = vec![0x0bu8]; /* WordPrefix */ + fn append_aml_bytes(&self, bytes: &mut Vec) { + bytes.push(0x0b); /* WordPrefix */ bytes.append(&mut self.to_le_bytes().to_vec()); - bytes } } pub type DWord = u32; impl Aml for DWord { - fn to_aml_bytes(&self) -> Vec { - let mut bytes = vec![0x0c]; /* DWordPrefix */ + fn append_aml_bytes(&self, bytes: &mut Vec) { + bytes.push(0x0c); /* DWordPrefix */ bytes.append(&mut self.to_le_bytes().to_vec()); - bytes } } pub type QWord = u64; impl Aml for QWord { - fn to_aml_bytes(&self) -> Vec { - let mut bytes = vec![0x0e]; /* QWordPrefix */ + fn append_aml_bytes(&self, bytes: &mut Vec) { + bytes.push(0x0e); /* QWordPrefix */ bytes.append(&mut self.to_le_bytes().to_vec()); - bytes } }