pub struct MockQuantumBackend {
pub config: MockBackendConfig,
/* private fields */
}Expand description
A configurable mock quantum backend for use in integration tests.
All submitted jobs are recorded and can be retrieved via MockQuantumBackend::all_jobs.
Measurement results are generated deterministically from the configured seed so that
tests are reproducible.
Fields§
§config: MockBackendConfigPublic backend configuration
Implementations§
Source§impl MockQuantumBackend
impl MockQuantumBackend
Sourcepub fn new(config: MockBackendConfig) -> Self
pub fn new(config: MockBackendConfig) -> Self
Create a new mock backend with the given configuration.
Sourcepub fn all_jobs(&self) -> Vec<MockJobRecord>
pub fn all_jobs(&self) -> Vec<MockJobRecord>
Return a snapshot of all job records accumulated so far.
Sourcepub fn last_job(&self) -> Option<MockJobRecord>
pub fn last_job(&self) -> Option<MockJobRecord>
Return the most recently submitted job, or None if no jobs have run.
Sourcepub fn run(
&self,
circuit_qasm: &str,
shots: usize,
) -> Result<HashMap<String, usize>, MockBackendError>
pub fn run( &self, circuit_qasm: &str, shots: usize, ) -> Result<HashMap<String, usize>, MockBackendError>
Submit a QASM 2.0 circuit and return measurement counts.
Validates qubit and shot limits, optionally simulates latency, optionally
injects a simulated failure, then generates and returns measurement counts.
Every invocation appends a MockJobRecord to the backend’s log.
Sourcepub fn capabilities(&self) -> HashMap<String, String>
pub fn capabilities(&self) -> HashMap<String, String>
Return a map of backend capabilities (suitable for display / comparison).
Sourcepub fn supports_gate(&self, gate_name: &str) -> bool
pub fn supports_gate(&self, gate_name: &str) -> bool
Return true when the given gate name is supported by this backend.
An empty gate set (the default) means every gate is accepted.
Sourcepub fn is_connected(&self, q0: usize, q1: usize) -> bool
pub fn is_connected(&self, q0: usize, q1: usize) -> bool
Return true when the pair (q0, q1) is a valid 2-qubit connection.
An empty connectivity list (the default) means all pairs are allowed.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MockQuantumBackend
impl RefUnwindSafe for MockQuantumBackend
impl Send for MockQuantumBackend
impl Sync for MockQuantumBackend
impl Unpin for MockQuantumBackend
impl UnsafeUnpin for MockQuantumBackend
impl UnwindSafe for MockQuantumBackend
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
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.