def AmlValue.to_buf

bend-osdev-acpi@0.1.1.0 · aml_value.bend:204

import bend-osdev-acpi@0.1.1.0/aml_value.bend as AmlValue
import Base
import bend-osdev-bytes@0.1.1.0/bytes.bend as B
import bend-osdev-acpi@0.1.1.0/error.bend as E

204# the implicit conversion to Buffer: an integer's 8 (or 4) bytes,
205# little-endian; a string's bytes and its NUL
206def AmlValue.to_buf(+wide: Bool, v: AmlValue) -> Result<&2, &2, E.AcpiError, B.Octets>:
207  match v:
208    case AmlInt{x}:
209      Done{val.int.bytes(wide, x)}
210    case AmlBuf{b}:
211      Done{b}
212    case AmlStr{s}:
213      Done{B.Octets.append(s, B.Octets.of_list([0]))}
214    case _:
215      Fail{E.AcpiAmlBadType{"cannot convert to a buffer"}}

Uses (9)

Used by (5)