• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Qiskit / qiskit / 14907095122

08 May 2025 01:01PM CUT coverage: 87.843% (-0.001%) from 87.844%
14907095122

Pull #14314

github

web-flow
Merge f338b045e into 25972ae86
Pull Request #14314: Add C API function to move a QkCircuit to Python

0 of 11 new or added lines in 1 file covered. (0.0%)

96 existing lines in 4 files now uncovered.

74605 of 84930 relevant lines covered (87.84%)

432644.99 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/crates/cext/src/exit_codes.rs
1
// This code is part of Qiskit.
2
//
3
// (C) Copyright IBM 2024
4
//
5
// This code is licensed under the Apache License, Version 2.0. You may
6
// obtain a copy of this license in the LICENSE.txt file in the root directory
7
// of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
8
//
9
// Any modifications or derivative works of this code must retain this
10
// copyright notice, and modified files need to carry a notice indicating
11
// that they have been altered from the originals.
12

13
use qiskit_accelerate::sparse_observable::ArithmeticError;
14
use thiserror::Error;
15

16
/// Errors related to C input.
17
#[derive(Error, Debug)]
18
pub enum CInputError {
19
    #[error("Unexpected null pointer.")]
20
    NullPointerError,
21
    #[error("Non-aligned memory.")]
22
    AlignmentError,
23
    #[error("Index out of bounds.")]
24
    IndexError,
25
}
26

27
/// Integer exit codes returned to C.
28
#[repr(u32)]
29
pub enum ExitCode {
30
    /// Success.
31
    Success = 0,
32
    /// Error related to data input.
33
    CInputError = 100,
34
    /// Unexpected null pointer.
35
    NullPointerError = 101,
36
    /// Pointer is not aligned to expected data.
37
    AlignmentError = 102,
38
    /// Index out of bounds.
39
    IndexError = 103,
40
    /// Error related to arithmetic operations or similar.
41
    ArithmeticError = 200,
42
    /// Mismatching number of qubits.
43
    MismatchedQubits = 201,
44
}
45

46
impl From<ArithmeticError> for ExitCode {
47
    fn from(value: ArithmeticError) -> Self {
×
48
        match value {
×
49
            ArithmeticError::MismatchedQubits { left: _, right: _ } => ExitCode::MismatchedQubits,
×
50
        }
×
51
    }
×
52
}
53

54
impl From<CInputError> for ExitCode {
55
    fn from(value: CInputError) -> Self {
×
56
        match value {
×
57
            CInputError::AlignmentError => ExitCode::AlignmentError,
×
58
            CInputError::NullPointerError => ExitCode::NullPointerError,
×
59
            CInputError::IndexError => ExitCode::IndexError,
×
60
        }
61
    }
×
62
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc