sv_api/
result.rs

1/*
2 * File:    TODO.rs
3 * Brief:   TODO
4 *
5 * Copyright (C) TODO John Jekel
6 * See the LICENSE file at the root of the project for licensing info.
7 *
8 * TODO longer description
9 *
10*/
11
12/*!
13 * TODO rustdoc for this file here
14*/
15
16/* ------------------------------------------------------------------------------------------------
17 * Submodules
18 * --------------------------------------------------------------------------------------------- */
19
20//TODO (includes "mod ..." and "pub mod ...")
21
22/* ------------------------------------------------------------------------------------------------
23 * Uses
24 * --------------------------------------------------------------------------------------------- */
25
26use std::fmt;
27use std::fmt::Display;
28
29/* ------------------------------------------------------------------------------------------------
30 * Macros
31 * --------------------------------------------------------------------------------------------- */
32
33//TODO (also pub(crate) use the_macro statements here too)
34
35/* ------------------------------------------------------------------------------------------------
36 * Constants
37 * --------------------------------------------------------------------------------------------- */
38
39//TODO
40
41/* ------------------------------------------------------------------------------------------------
42 * Static Variables
43 * --------------------------------------------------------------------------------------------- */
44
45//TODO
46
47/* ------------------------------------------------------------------------------------------------
48 * Types
49 * --------------------------------------------------------------------------------------------- */
50
51#[derive(Debug)]
52#[non_exhaustive]
53pub enum Error {
54    Unknown,
55    //TODO others
56    Reason {
57        //TODO populate with what the standard provides through vpi_chk_error
58        todo: String,
59    },
60    Other(Box<dyn std::error::Error>)//A non sv-api error
61}
62
63pub type Result<T> = std::result::Result<T, Box<Error>>;
64
65/* ------------------------------------------------------------------------------------------------
66 * Associated Functions and Methods
67 * --------------------------------------------------------------------------------------------- */
68
69//TODO
70
71/* ------------------------------------------------------------------------------------------------
72 * Traits And Default Implementations
73 * --------------------------------------------------------------------------------------------- */
74
75//TODO
76
77/* ------------------------------------------------------------------------------------------------
78 * Trait Implementations
79 * --------------------------------------------------------------------------------------------- */
80
81impl std::error::Error for Error {
82    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
83        match self {
84            Error::Other(other_boxed_error) => Some(other_boxed_error.as_ref()),
85            _ => None
86        }
87    }
88}
89
90impl Display for Error {
91    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> fmt::Result {
92        match self {
93            Error::Unknown                  => write!(f, "Unknown or unclassified error"),
94            Error::Reason { todo }          => write!(f, "Reason: {}", todo),//TODO display this properly
95            Error::Other(other_boxed_error) => write!(f, "Other: {}", other_boxed_error)
96        }
97    }
98}
99
100/* ------------------------------------------------------------------------------------------------
101 * Functions
102 * --------------------------------------------------------------------------------------------- */
103
104//TODO
105
106/* ------------------------------------------------------------------------------------------------
107 * Tests
108 * --------------------------------------------------------------------------------------------- */
109
110//TODO
111
112/* ------------------------------------------------------------------------------------------------
113 * Benchmarks
114 * --------------------------------------------------------------------------------------------- */
115
116//TODO