acpi_tables: aml: Implement Aml::append_aml_bytes() for AmlStr and AmlString

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2021-11-03 14:29:05 +00:00
parent 93647f0313
commit d92489e0a4

View File

@ -276,26 +276,25 @@ impl Aml for Usize {
} }
} }
fn create_aml_string(v: &str) -> Vec<u8> { fn append_aml_string(v: &str, bytes: &mut Vec<u8>) {
let mut data = vec![0x0D]; /* String Op */ bytes.push(0x0D); /* String Op */
data.extend_from_slice(v.as_bytes()); bytes.extend_from_slice(v.as_bytes());
data.push(0x0); /* NullChar */ bytes.push(0x0); /* NullChar */
data
} }
pub type AmlStr = &'static str; pub type AmlStr = &'static str;
impl Aml for AmlStr { impl Aml for AmlStr {
fn to_aml_bytes(&self) -> Vec<u8> { fn append_aml_bytes(&self, bytes: &mut Vec<u8>) {
create_aml_string(self) append_aml_string(self, bytes)
} }
} }
pub type AmlString = String; pub type AmlString = String;
impl Aml for AmlString { impl Aml for AmlString {
fn to_aml_bytes(&self) -> Vec<u8> { fn append_aml_bytes(&self, bytes: &mut Vec<u8>) {
create_aml_string(self) append_aml_string(self, bytes)
} }
} }