pub enum ResultData {
Qvm(QvmResultData),
Qpu(QpuResultData),
}Expand description
Represents the two possible types of data returned from either the QVM or a real QPU. Each variant contains the original data returned from its respective executor.
§Usage
Your usage of ResultData will depend on the types of programs you are running and where.
The to_register_map() method will attempt to build a RegisterMap out of the data, where each
register name is mapped to a 2-dimensional rectangular RegisterMatrix where each row
represents the final values in each register index for a particular shot. This is often the
desired form of the data and it is probably what you want. This transformation isn’t always
possible, in which case to_register_map() will return an error.
To understand why this transformation can fail, we need to understand a bit about how readout data is returned from the QVM and from a real QPU:
The QVM treats each DECLARE statement as initialzing some amount of memory. This memory works
as one might expect it to. It is zero-initialized on each shot, and subsequent writes to the same region
overwrite the previous value. The QVM returns memory at the end of every shot. This means
we get the last value in every memory reference for each shot, which is exactly the
representation we want for a RegisterMatrix. For this reason, to_register_map() should
always succeed for ResultData::Qvm.
The QPU on the other hand doesn’t use the same memory model as the QVM. Each memory reference
(ie. “ro[0]”) is more like a stream than a value in memory. Every MEASURE to a memory
reference emits a new value to said stream. This means that the number of values per memory
reference can vary per shot. For this reason, it’s not always clear what the final value in
each shot was for a particular reference. When this is the case, to_register_map() will return
an error as it’s impossible to build a correct RegisterMatrix from the data without
knowing the intent of the program that was run. Instead, it’s recommended to build the
RegisterMatrix you need from the inner QpuResultData data using the knowledge of your
program to choose the correct readout values for each shot.
Variants§
Qvm(QvmResultData)
Data returned from the QVM, stored as QvmResultData
Qpu(QpuResultData)
Readout data returned from the QPU, stored as QpuResultData
Implementations§
Source§impl ResultData
impl ResultData
Sourcepub fn as_qvm_mut(&mut self) -> Option<&mut QvmResultData>
pub fn as_qvm_mut(&mut self) -> Option<&mut QvmResultData>
Optionally returns mutable references to the inner fields if this is a ResultData::Qvm, otherwise None
Sourcepub fn as_qvm(&self) -> Option<&QvmResultData>
pub fn as_qvm(&self) -> Option<&QvmResultData>
Optionally returns references to the inner fields if this is a ResultData::Qvm, otherwise None
Sourcepub fn into_qvm(self) -> Result<QvmResultData, Self>
pub fn into_qvm(self) -> Result<QvmResultData, Self>
Returns the inner fields if this is a ResultData::Qvm, otherwise returns back the enum in the Err case of the result
Sourcepub fn as_qpu_mut(&mut self) -> Option<&mut QpuResultData>
pub fn as_qpu_mut(&mut self) -> Option<&mut QpuResultData>
Optionally returns mutable references to the inner fields if this is a ResultData::Qpu, otherwise None
Sourcepub fn as_qpu(&self) -> Option<&QpuResultData>
pub fn as_qpu(&self) -> Option<&QpuResultData>
Optionally returns references to the inner fields if this is a ResultData::Qpu, otherwise None
Sourcepub fn into_qpu(self) -> Result<QpuResultData, Self>
pub fn into_qpu(self) -> Result<QpuResultData, Self>
Returns the inner fields if this is a ResultData::Qpu, otherwise returns back the enum in the Err case of the result
Source§impl ResultData
impl ResultData
Sourcepub fn to_register_map(
&self,
) -> Result<RegisterMap, RegisterMatrixConversionError>
pub fn to_register_map( &self, ) -> Result<RegisterMap, RegisterMatrixConversionError>
Convert ResultData from its inner representation as QvmResultData or
QpuResultData into a RegisterMap. The RegisterMatrix for each register will be
constructed such that each row contains all the final values in the register for a single shot.
§Errors
Returns a RegisterMatrixConversionError if the inner execution data for any of the
registers would result in a jagged matrix. QpuResultData data is captured per measure,
meaning a value is returned for every measure to a memory reference, not just once per shot.
This is often the case in programs that use mid-circuit measurement or dynamic control flow,
where measurements to the same memory reference might occur multiple times in a shot, or be
skipped conditionally. In these cases, building a rectangular RegisterMatrix would
necessitate making assumptions about the data that could skew the data in undesirable ways.
Instead, it’s recommended to manually build a matrix from QpuResultData that accurately
selects the last value per-shot based on the program that was run.
Trait Implementations§
Source§impl Clone for ResultData
impl Clone for ResultData
Source§fn clone(&self) -> ResultData
fn clone(&self) -> ResultData
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ResultData
impl Debug for ResultData
Source§impl<'de> Deserialize<'de> for ResultData
impl<'de> Deserialize<'de> for ResultData
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for ResultData
impl PartialEq for ResultData
Source§impl Serialize for ResultData
impl Serialize for ResultData
impl StructuralPartialEq for ResultData
Auto Trait Implementations§
impl Freeze for ResultData
impl RefUnwindSafe for ResultData
impl Send for ResultData
impl Sync for ResultData
impl Unpin for ResultData
impl UnwindSafe for ResultData
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Returns self with the
fg()
set to
Color::BrightBlack.
§Example
println!("{}", value.bright_black());Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Returns self with the
fg()
set to
Color::BrightGreen.
§Example
println!("{}", value.bright_green());Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Returns self with the
fg()
set to
Color::BrightYellow.
§Example
println!("{}", value.bright_yellow());Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Returns self with the
fg()
set to
Color::BrightMagenta.
§Example
println!("{}", value.bright_magenta());Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Returns self with the
fg()
set to
Color::BrightWhite.
§Example
println!("{}", value.bright_white());Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Returns self with the
bg()
set to
Color::BrightBlack.
§Example
println!("{}", value.on_bright_black());Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Returns self with the
bg()
set to
Color::BrightGreen.
§Example
println!("{}", value.on_bright_green());Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Returns self with the
bg()
set to
Color::BrightYellow.
§Example
println!("{}", value.on_bright_yellow());Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Returns self with the
bg()
set to
Color::BrightBlue.
§Example
println!("{}", value.on_bright_blue());Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Returns self with the
bg()
set to
Color::BrightMagenta.
§Example
println!("{}", value.on_bright_magenta());Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Returns self with the
bg()
set to
Color::BrightCyan.
§Example
println!("{}", value.on_bright_cyan());Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Returns self with the
bg()
set to
Color::BrightWhite.
§Example
println!("{}", value.on_bright_white());Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn underline(&self) -> Painted<&T>
fn underline(&self) -> Painted<&T>
Returns self with the
attr()
set to
Attribute::Underline.
§Example
println!("{}", value.underline());Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Returns self with the
attr()
set to
Attribute::RapidBlink.
§Example
println!("{}", value.rapid_blink());Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.