Function simics::api::base::attr_value::attr_string

source ·
pub fn attr_string(attr: &AttrValue) -> Result<String>
Expand description

Get an AttrValue as a String.

Unlike the C API function, which transfers ownership of the string to the caller and replaces the value in the AttrValue with a nil value, this function copies the string and takes ownership of the new string. The old string’s ownership is not changed, and it is not freed.

§Arguments

  • attr - The AttrValue to attempt to get as a String

§Return Value

The contained string value if the AttrValue is the correct type, or an error otherwise.

§Notes

Conversion via TryInto should be preferred. For example:

let x: String = a.try_into()?;

§Context

All Contexts