pub trait Quil: Debug {
// Required method
fn write(
&self,
writer: &mut impl Write,
fall_back_to_debug: bool,
) -> Result<(), ToQuilError>;
// Provided methods
fn to_quil(&self) -> Result<String, ToQuilError> { ... }
fn to_quil_or_debug(&self) -> String { ... }
}
Expand description
A trait to wrap items which represent some construct within the Quil language.
If you want to serialize an object to string and fail if it can’t be represented as valid Quil, then use
to_quil()
. If you want to serialize an object to string infallibly, and can tolerate invalid Quil, then
use to_quil_or_debug()
.
Required Methods§
Provided Methods§
Sourcefn to_quil(&self) -> Result<String, ToQuilError>
fn to_quil(&self) -> Result<String, ToQuilError>
Return a string in valid Quil syntax or an error if the item cannot be represented with valid Quil.
Sourcefn to_quil_or_debug(&self) -> String
fn to_quil_or_debug(&self) -> String
Return a string in valid Quil syntax if possible. Any individual component of this object
which cannot be represented in Quil will be replaced with a Debug
representation of that
component.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.