1use thiserror::Error;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
6#[repr(i32)]
7pub enum PvStat {
8 Ok = 0,
9 Error = -1,
10 Timeout = -2,
11 Disconnected = -3,
12}
13
14#[derive(Debug, Clone)]
16pub struct PvOpResult {
17 pub stat: PvStat,
18 pub severity: i16,
19 pub message: Option<String>,
20}
21
22impl Default for PvOpResult {
23 fn default() -> Self {
24 Self {
25 stat: PvStat::Ok,
26 severity: 0,
27 message: None,
28 }
29 }
30}
31
32#[derive(Debug, Error)]
33pub enum SeqError {
34 #[error("channel not connected: {0}")]
35 NotConnected(String),
36
37 #[error("channel access error: {0}")]
38 CaError(#[from] epics_base_rs::error::CaError),
39
40 #[error("invalid channel id: {0}")]
41 InvalidChannelId(usize),
42
43 #[error("invalid event flag id: {0}")]
44 InvalidEventFlagId(usize),
45
46 #[error("invalid state id: {0}")]
47 InvalidStateId(usize),
48
49 #[error("type mismatch for channel {channel}: expected {expected}, got {actual}")]
50 TypeMismatch {
51 channel: String,
52 expected: String,
53 actual: String,
54 },
55
56 #[error("program shutdown")]
57 Shutdown,
58
59 #[error("{0}")]
60 Other(String),
61}
62
63pub type SeqResult<T> = Result<T, SeqError>;