def AmlValue.to_str

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

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

247# the implicit conversion to String: an integer as 16 (or 8) hex digits; a
248# buffer as two hex digits per byte, separated by spaces
249def AmlValue.to_str(+wide: Bool, v: AmlValue) -> Result<&2, &2, E.AcpiError, B.Octets>:
250  match v:
251    case AmlInt{x}:
252      Done{B.Octets.of_list(val.hex.text(Nat.mul(2n, AmlInt.width_bytes(wide)), x, Nil{}))}
253    case AmlStr{s}:
254      Done{s}
255    case AmlBuf{b}:
256      Done{B.Octets.of_list(val.buf.text(B.Octets.to_list(b), True{}))}
257    case _:
258      Fail{E.AcpiAmlBadType{"cannot convert to a string"}}

Uses (12)

Used by (4)