Debian Codegraph @

src/error.rs

raw symbols SCIP
1 //! There be Errors here.
2
3 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/;
4
5 use cxxrust-analyzer cargo cxx 1.0.199 crate/::Exceptionrust-analyzer cargo cxx 1.0.199 exception/Exception#;
6 #[doc(inline)]
7 pub use rawrust-analyzer cargo rust-apt 0.8.0 error/raw/::{emptyrust-analyzer cargo rust-apt 0.8.0 error/raw/empty()., pending_errorrust-analyzer cargo rust-apt 0.8.0 error/raw/pending_error()., AptErrorrust-analyzer cargo rust-apt 0.8.0 error/raw/AptError#};
8
9 #[cxxrust-analyzer cargo cxx 1.0.199 crate/::bridgerust-analyzer cargo cxxbridge-macro 1.0.199 bridge:]
10 pub(craterust-analyzer cargo rust-apt 0.8.0 crate/) mod rawrust-analyzer cargo rust-apt 0.8.0 error/raw/ {
11 /// Representation of a single Apt Error or Warning
12 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#)]
13 struct AptErrorrust-analyzer cargo rust-apt 0.8.0 error/raw/AptError# {
14 /// * [`true`] = Error.
15 /// * [`false`] = Warning, Notice, etc.
16 pub is_errorrust-analyzer cargo rust-apt 0.8.0 error/raw/AptError#is_error.: bool,
17 /// The String version of the Error.
18 pub msgrust-analyzer cargo rust-apt 0.8.0 error/raw/AptError#msg.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
19 }
20
21 unsafe extern "C++" {
22 includerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/include!!("rust-apt/apt-pkg-c/error.h");
23
24 /// Returns [`true`] if there are any pending Apt Errors.
25 pub fn pending_errorrust-analyzer cargo rust-apt 0.8.0 error/raw/pending_error().() -> bool;
26
27 /// Returns [`true`] if there are no Errors or Warnings.
28 pub fn emptyrust-analyzer cargo rust-apt 0.8.0 error/raw/empty().() -> bool;
29
30 /// Returns all Apt Errors or Warnings.
31 pub fn get_allrust-analyzer cargo rust-apt 0.8.0 error/raw/get_all().() -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<AptErrorrust-analyzer cargo rust-apt 0.8.0 error/raw/AptError#>;
32 }
33 }
34
35 impl fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for AptErrorrust-analyzer cargo rust-apt 0.8.0 error/raw/AptError# {
36 fn fmtrust-analyzer cargo rust-apt 0.8.0 error/impl#[AptError][Display]fmt().(&self, f: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
37 if self.is_errorrust-analyzer cargo rust-apt 0.8.0 error/raw/AptError#is_error. {
38 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "E: {}", self.msgrust-analyzer cargo rust-apt 0.8.0 error/raw/AptError#msg.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
39 } else {
40 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "W: {}", self.msgrust-analyzer cargo rust-apt 0.8.0 error/raw/AptError#msg.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
41 }
42
43 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
44 }
45 }
46
47 impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for AptErrorrust-analyzer cargo rust-apt 0.8.0 error/raw/AptError# {}
48
49 /// Struct that represents multiple apt errors and warnings.
50 ///
51 /// This is essentially just a wrapper around [`Vec<AptError>`]
52 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
53 pub struct AptErrorsrust-analyzer cargo rust-apt 0.8.0 error/AptErrors# {
54 pub(craterust-analyzer cargo rust-apt 0.8.0 crate/) ptrrust-analyzer cargo rust-apt 0.8.0 error/AptErrors#ptr.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<AptErrorrust-analyzer cargo rust-apt 0.8.0 error/raw/AptError#>,
55 }
56
57 impl AptErrorsrust-analyzer cargo rust-apt 0.8.0 error/AptErrors# {
58 pub fn newrust-analyzer cargo rust-apt 0.8.0 error/impl#[AptErrors]new().() -> AptErrorsrust-analyzer cargo rust-apt 0.8.0 error/AptErrors# {
59 AptErrorsrust-analyzer cargo rust-apt 0.8.0 error/AptErrors# {
60 ptrrust-analyzer cargo rust-apt 0.8.0 error/AptErrors#ptr.: rawrust-analyzer cargo rust-apt 0.8.0 error/raw/::get_allrust-analyzer cargo rust-apt 0.8.0 error/raw/get_all().(),
61 }
62 }
63 }
64
65 impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for AptErrorsrust-analyzer cargo rust-apt 0.8.0 error/AptErrors# {
66 fn defaultrust-analyzer cargo rust-apt 0.8.0 error/impl#[AptErrors][Default]default().() -> Selfrust-analyzer cargo rust-apt 0.8.0 error/impl#[AptErrors][Default] { Selfrust-analyzer cargo rust-apt 0.8.0 error/impl#[AptErrors][Default]::newrust-analyzer cargo rust-apt 0.8.0 error/impl#[AptErrors]new().() }
67 }
68
69 impl fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for AptErrorsrust-analyzer cargo rust-apt 0.8.0 error/AptErrors# {
70 fn fmtrust-analyzer cargo rust-apt 0.8.0 error/impl#[AptErrors][Display]fmt().(&self, f: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
71 for error in self.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() {
72 writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(f, "{error}")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
73 }
74 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
75 }
76 }
77
78 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> for AptErrorsrust-analyzer cargo rust-apt 0.8.0 error/AptErrors# {
79 fn fromrust-analyzer cargo rust-apt 0.8.0 error/impl#[AptErrors][`From<String>`]from().(err: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> Selfrust-analyzer cargo rust-apt 0.8.0 error/impl#[AptErrors][`From<String>`] {
80 AptErrorsrust-analyzer cargo rust-apt 0.8.0 error/AptErrors# {
81 ptrrust-analyzer cargo rust-apt 0.8.0 error/AptErrors#ptr.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![AptErrorrust-analyzer cargo rust-apt 0.8.0 error/raw/AptError# {
82 is_errorrust-analyzer cargo rust-apt 0.8.0 error/raw/AptError#is_error.: true,
83 msgrust-analyzer cargo rust-apt 0.8.0 error/raw/AptError#msg.: err,
84 }],
85 }
86 }
87 }
88
89 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Exceptionrust-analyzer cargo cxx 1.0.199 exception/Exception#> for AptErrorsrust-analyzer cargo rust-apt 0.8.0 error/AptErrors# {
90 fn fromrust-analyzer cargo rust-apt 0.8.0 error/impl#[AptErrors][`From<Exception>`]from().(err: Exceptionrust-analyzer cargo cxx 1.0.199 exception/Exception#) -> Selfrust-analyzer cargo rust-apt 0.8.0 error/impl#[AptErrors][`From<Exception>`] {
91 if err.whatrust-analyzer cargo cxx 1.0.199 exception/impl#[Exception]what().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."convert to AptErrors" {
92 return AptErrorsrust-analyzer cargo rust-apt 0.8.0 error/AptErrors#::newrust-analyzer cargo rust-apt 0.8.0 error/impl#[AptErrors]new().();
93 }
94 // The times where it's not an Apt error to be converted are slim
95 AptErrorsrust-analyzer cargo rust-apt 0.8.0 error/AptErrors#::fromrust-analyzer cargo rust-apt 0.8.0 error/impl#[AptErrors][`From<String>`]from().(err.whatrust-analyzer cargo cxx 1.0.199 exception/impl#[Exception]what().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
96 }
97 }
98
99 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#> for AptErrorsrust-analyzer cargo rust-apt 0.8.0 error/AptErrors# {
100 fn fromrust-analyzer cargo rust-apt 0.8.0 error/impl#[AptErrors][`From<std::io::Error>`]from().(err: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#) -> Selfrust-analyzer cargo rust-apt 0.8.0 error/impl#[AptErrors][`From<std::io::Error>`] { AptErrorsrust-analyzer cargo rust-apt 0.8.0 error/AptErrors#::fromrust-analyzer cargo rust-apt 0.8.0 error/impl#[AptErrors][`From<String>`]from().(err.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) }
101 }
102
103 impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for AptErrorsrust-analyzer cargo rust-apt 0.8.0 error/AptErrors# {}