pub struct Error(/* private fields */);Expand description
A small container retaining the typed error from a Bloq workflow.
Subsystem APIs keep their concrete errors. In a function returning Result,
? wraps those errors automatically. Use Self::downcast_ref to inspect
the original error and StdError::source to traverse its causes.
Application-specific errors can be wrapped with Self::new.
use bloq::prelude::*;
fn circuit_text(source: &str) -> Result<String> {
let graph = parse_blog_to_graph(source)?;
let config = CompileConfig::try_new(3)?;
let artifacts = compile_with(&graph, config)?;
Ok(emit_bloq_stim(&artifacts.bloq)?)
}
let error = circuit_text("invalid BLOG").unwrap_err();
assert!(error.is::<bloq::graph::BlockGraphError>());Implementations§
Source§impl Error
impl Error
Sourcepub fn new(error: impl StdError + Send + Sync + 'static) -> Self
pub fn new(error: impl StdError + Send + Sync + 'static) -> Self
Wrap an owned error, retaining its type, message, and causes.
let error = bloq::Error::new("invalid".parse::<u32>().unwrap_err());
assert!(error.is::<std::num::ParseIntError>());Sourcepub fn downcast_ref<E: StdError + 'static>(&self) -> Option<&E>
pub fn downcast_ref<E: StdError + 'static>(&self) -> Option<&E>
Borrow the original error if it has type E.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<BinaryDecodeError> for Error
impl From<BinaryDecodeError> for Error
Source§fn from(error: BinaryDecodeError) -> Self
fn from(error: BinaryDecodeError) -> Self
Source§impl From<BlockError> for Error
impl From<BlockError> for Error
Source§fn from(error: BlockError) -> Self
fn from(error: BlockError) -> Self
Source§impl From<BlockGraphError> for Error
impl From<BlockGraphError> for Error
Source§fn from(error: BlockGraphError) -> Self
fn from(error: BlockGraphError) -> Self
Source§impl From<BloqStatsError> for Error
impl From<BloqStatsError> for Error
Source§fn from(error: BloqStatsError) -> Self
fn from(error: BloqStatsError) -> Self
Source§impl From<BloqValidationError> for Error
impl From<BloqValidationError> for Error
Source§fn from(error: BloqValidationError) -> Self
fn from(error: BloqValidationError) -> Self
Source§impl From<BooleanResourceError> for Error
impl From<BooleanResourceError> for Error
Source§fn from(error: BooleanResourceError) -> Self
fn from(error: BooleanResourceError) -> Self
Source§impl From<CircuitError> for Error
impl From<CircuitError> for Error
Source§fn from(error: CircuitError) -> Self
fn from(error: CircuitError) -> Self
Source§impl From<CompileError> for Error
impl From<CompileError> for Error
Source§fn from(error: CompileError) -> Self
fn from(error: CompileError) -> Self
Source§impl From<CoordinateOverflowError> for Error
impl From<CoordinateOverflowError> for Error
Source§fn from(error: CoordinateOverflowError) -> Self
fn from(error: CoordinateOverflowError) -> Self
Source§impl From<CycleDetected> for Error
impl From<CycleDetected> for Error
Source§fn from(error: CycleDetected) -> Self
fn from(error: CycleDetected) -> Self
Source§impl From<DecoderError> for Error
Available on crate feature vm only.
impl From<DecoderError> for Error
vm only.Source§fn from(error: DecoderError) -> Self
fn from(error: DecoderError) -> Self
Source§impl From<DetectorBundleError> for Error
impl From<DetectorBundleError> for Error
Source§fn from(error: DetectorBundleError) -> Self
fn from(error: DetectorBundleError) -> Self
Source§impl From<DetsliceError> for Error
impl From<DetsliceError> for Error
Source§fn from(error: DetsliceError) -> Self
fn from(error: DetsliceError) -> Self
Source§impl From<DirectionParseError> for Error
impl From<DirectionParseError> for Error
Source§fn from(error: DirectionParseError) -> Self
fn from(error: DirectionParseError) -> Self
Source§impl From<FeedbackInferenceError> for Error
Available on crate feature graph-verify only.
impl From<FeedbackInferenceError> for Error
graph-verify only.Source§fn from(error: FeedbackInferenceError) -> Self
fn from(error: FeedbackInferenceError) -> Self
Source§impl From<FillPortsError> for Error
impl From<FillPortsError> for Error
Source§fn from(error: FillPortsError) -> Self
fn from(error: FillPortsError) -> Self
Source§impl From<FlattenError> for Error
impl From<FlattenError> for Error
Source§fn from(error: FlattenError) -> Self
fn from(error: FlattenError) -> Self
Source§impl From<InvalidActionError> for Error
impl From<InvalidActionError> for Error
Source§fn from(error: InvalidActionError) -> Self
fn from(error: InvalidActionError) -> Self
Source§impl From<InvalidBlockGraphError> for Error
impl From<InvalidBlockGraphError> for Error
Source§fn from(error: InvalidBlockGraphError) -> Self
fn from(error: InvalidBlockGraphError) -> Self
Source§impl From<InvalidDistance> for Error
impl From<InvalidDistance> for Error
Source§fn from(error: InvalidDistance) -> Self
fn from(error: InvalidDistance) -> Self
Source§impl From<LowerError> for Error
Available on crate feature vm only.
impl From<LowerError> for Error
vm only.Source§fn from(error: LowerError) -> Self
fn from(error: LowerError) -> Self
Source§impl From<MeasurementFrameError> for Error
impl From<MeasurementFrameError> for Error
Source§fn from(error: MeasurementFrameError) -> Self
fn from(error: MeasurementFrameError) -> Self
Source§impl From<MembershipPinError> for Error
impl From<MembershipPinError> for Error
Source§fn from(error: MembershipPinError) -> Self
fn from(error: MembershipPinError) -> Self
Source§impl From<ModuleCertificationError> for Error
impl From<ModuleCertificationError> for Error
Source§fn from(error: ModuleCertificationError) -> Self
fn from(error: ModuleCertificationError) -> Self
Source§impl From<ModuleError> for Error
impl From<ModuleError> for Error
Source§fn from(error: ModuleError) -> Self
fn from(error: ModuleError) -> Self
Source§impl From<MomentAlignmentError> for Error
impl From<MomentAlignmentError> for Error
Source§fn from(error: MomentAlignmentError) -> Self
fn from(error: MomentAlignmentError) -> Self
Source§impl From<OutputCorrectionError> for Error
impl From<OutputCorrectionError> for Error
Source§fn from(error: OutputCorrectionError) -> Self
fn from(error: OutputCorrectionError) -> Self
Source§impl From<ParseError> for Error
impl From<ParseError> for Error
Source§fn from(error: ParseError) -> Self
fn from(error: ParseError) -> Self
Source§impl From<PauliError> for Error
impl From<PauliError> for Error
Source§fn from(error: PauliError) -> Self
fn from(error: PauliError) -> Self
Source§impl From<ProgramSliceError> for Error
impl From<ProgramSliceError> for Error
Source§fn from(error: ProgramSliceError) -> Self
fn from(error: ProgramSliceError) -> Self
Source§impl From<ResolveDomainError> for Error
impl From<ResolveDomainError> for Error
Source§fn from(error: ResolveDomainError) -> Self
fn from(error: ResolveDomainError) -> Self
Source§impl From<ResolveError> for Error
impl From<ResolveError> for Error
Source§fn from(error: ResolveError) -> Self
fn from(error: ResolveError) -> Self
Source§impl From<RuntimeBasisError> for Error
impl From<RuntimeBasisError> for Error
Source§fn from(error: RuntimeBasisError) -> Self
fn from(error: RuntimeBasisError) -> Self
Source§impl From<RuntimeError> for Error
Available on crate feature vm only.
impl From<RuntimeError> for Error
vm only.Source§fn from(error: RuntimeError) -> Self
fn from(error: RuntimeError) -> Self
Source§impl From<StabilizerError> for Error
impl From<StabilizerError> for Error
Source§fn from(error: StabilizerError) -> Self
fn from(error: StabilizerError) -> Self
Source§impl From<StimEmissionError> for Error
impl From<StimEmissionError> for Error
Source§fn from(error: StimEmissionError) -> Self
fn from(error: StimEmissionError) -> Self
Source§impl From<StimNoiseError> for Error
Available on crate feature verify only.
impl From<StimNoiseError> for Error
verify only.Source§fn from(error: StimNoiseError) -> Self
fn from(error: StimNoiseError) -> Self
Source§impl From<StimVerifyError> for Error
Available on crate feature verify only.
impl From<StimVerifyError> for Error
verify only.Source§fn from(error: StimVerifyError) -> Self
fn from(error: StimVerifyError) -> Self
Source§impl From<StructureError> for Error
impl From<StructureError> for Error
Source§fn from(error: StructureError) -> Self
fn from(error: StructureError) -> Self
Source§impl From<SymbolicBasisError> for Error
impl From<SymbolicBasisError> for Error
Source§fn from(error: SymbolicBasisError) -> Self
fn from(error: SymbolicBasisError) -> Self
Source§impl From<TextParseError> for Error
impl From<TextParseError> for Error
Source§fn from(error: TextParseError) -> Self
fn from(error: TextParseError) -> Self
Source§impl From<UnknownCertificationLimit> for Error
impl From<UnknownCertificationLimit> for Error
Source§fn from(error: UnknownCertificationLimit) -> Self
fn from(error: UnknownCertificationLimit) -> Self
Source§impl From<VerifyLogicalError> for Error
Available on crate feature graph-verify only.
impl From<VerifyLogicalError> for Error
graph-verify only.Source§fn from(error: VerifyLogicalError) -> Self
fn from(error: VerifyLogicalError) -> Self
Auto Trait Implementations§
impl !RefUnwindSafe for Error
impl !UnwindSafe for Error
impl Freeze for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
Blanket Implementations§
§impl<T, BorrowedSelf> BitwiseMutViaBorrow<BorrowedSelf> for T
impl<T, BorrowedSelf> BitwiseMutViaBorrow<BorrowedSelf> for T
fn assign_index(&mut self, index: usize, to: bool)
fn negate_index(&mut self, index: usize)
fn clear_bits(&mut self)
fn assign_random(
&mut self,
bit_count: usize,
random_number_generator: &mut impl RngExt,
)where
BorrowedSelf: BitLength,
§impl<Bits, Other, BorrowedSelf, BorrowedOther> BitwisePairMutViaBorrow<Other, BorrowedSelf, BorrowedOther> for Bits
impl<Bits, Other, BorrowedSelf, BorrowedOther> BitwisePairMutViaBorrow<Other, BorrowedSelf, BorrowedOther> for Bits
fn assign(&mut self, other: &Other)
fn bitxor_assign(&mut self, other: &Other)
fn bitand_assign(&mut self, other: &Other)
fn bitor_assign(&mut self, other: &Other)
§impl<T, Other, BorrowedSelf, BorrowedOther> BitwisePairViaBorrow<Other, BorrowedSelf, BorrowedOther> for T
impl<T, Other, BorrowedSelf, BorrowedOther> BitwisePairViaBorrow<Other, BorrowedSelf, BorrowedOther> for T
§impl<T, BorrowedSelf> BitwiseViaBorrow<BorrowedSelf> for T
impl<T, BorrowedSelf> BitwiseViaBorrow<BorrowedSelf> for T
fn index(&self, index: usize) -> bool
fn weight(&self) -> usize
fn parity(&self) -> bool
fn is_zero(&self) -> bool
fn is_unit(&self, index: usize) -> bool
fn support<'a>(&'a self) -> impl SortedIteratorwhere
BorrowedSelf: 'a,
fn max_support(&self) -> Option<usize>
fn min_support(&self) -> Option<usize>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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 more§impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§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();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§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();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§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();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§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();§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>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§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);