roqoqo_iqm/lib.rs
1// Copyright © 2020-2023 HQS Quantum Simulations GmbH. All Rights Reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4// in compliance with the License. You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software distributed under the
9// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
10// express or implied. See the License for the specific language governing permissions and
11// limitations under the License.
12
13//! roqoqo-iqm
14//!
15
16#![deny(missing_docs)]
17#![warn(rustdoc::private_intra_doc_links)]
18#![warn(rustdoc::missing_crate_level_docs)]
19#![warn(rustdoc::missing_doc_code_examples)]
20#![warn(rustdoc::private_doc_tests)]
21#![deny(missing_debug_implementations)]
22
23use roqoqo::RoqoqoBackendError;
24use thiserror::Error;
25
26/// Errors that can occur in roqoqo-iqm
27#[derive(Error, Debug)]
28pub enum IqmBackendError {
29 /// Status of submitted job is FAILED
30 #[error("Job failed with job ID: {id}\nMessage: {msg}")]
31 JobFailed {
32 /// Job ID
33 id: String,
34 /// Message
35 msg: String,
36 },
37 /// Status of submitted job is ABORTED
38 #[error("Job with job ID {id} is aborted.")]
39 JobAborted {
40 /// Job ID
41 id: String,
42 },
43 /// Abortion of a job has failed
44 #[error("Could not abort job with ID {id}: {msg}")]
45 JobAbortionFailed {
46 /// Job ID
47 id: String,
48 /// Abort response from the endpoint
49 msg: String,
50 },
51 /// Result returned by IQM is empty
52 #[error("IQM has returned an empty result for job with ID {id}.")]
53 EmptyResult {
54 /// Job ID
55 id: String,
56 },
57 /// Circuit passed to the backend is empty
58 #[error("An empty circuit was passed to the backend.")]
59 EmptyCircuit,
60 /// Readout register is too small for the number of qubits in the circuit.
61 #[error("Readout register {name} is not large enough for the number of qubits.")]
62 RegisterTooSmall {
63 /// Name of the readout register
64 name: String,
65 },
66 /// Circuit passed to the backend is invalid
67 #[error("{msg}")]
68 InvalidCircuit {
69 /// Message
70 msg: String,
71 },
72 #[error("{msg}")]
73 /// Problem with circuit metadata in the results
74 MetadataError {
75 /// Message
76 msg: String,
77 },
78 #[error("{msg}")]
79 /// Received invalid results from the server
80 InvalidResults {
81 /// Message
82 msg: String,
83 },
84 /// Transparent propagation of RoqoqoBackendError
85 #[error(transparent)]
86 RoqoqoBackendError(#[from] RoqoqoBackendError),
87}
88
89mod interface;
90pub use interface::{
91 call_circuit, call_operation, virtual_z_replacement_circuit, IqmCircuit, IqmInstruction,
92};
93
94mod backend;
95pub use backend::*;
96
97pub mod devices;
98pub use devices::*;