Skip to content

Commit 28ca669

Browse files
authored
Update to chainerror 1.0 (#109)
I think eventually we want to use e.g. `thiserror` or `anyhow` (more widely used crates) but for now let's just update to the latest of this one.
2 parents 8a7ee17 + e7af919 commit 28ca669

File tree

7 files changed

+16
-17
lines changed

7 files changed

+16
-17
lines changed

varlink-certification/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ serde = "1.0.102"
1313
serde_derive = "1.0.102"
1414
serde_json = "1.0.41"
1515
getopts = "0.2.21"
16-
chainerror = "0.8.0"
16+
chainerror = "1"
1717

1818
[build-dependencies]
1919
varlink_generator = { path = "../varlink_generator" }

varlink-certification/src/main.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ use std::process::exit;
66
use std::sync::{Arc, RwLock};
77
use std::time::Instant;
88

9-
use chainerror::prelude::v1::*;
10-
119
pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
1210

11+
use chainerror::Context;
1312
use varlink::{Connection, StringHashMap, StringHashSet, VarlinkService};
1413

1514
mod org_varlink_certification {
@@ -685,13 +684,13 @@ impl org_varlink_certification::VarlinkInterface for CertInterface {
685684
}
686685
}
687686

688-
struct Context {
687+
struct TestContext {
689688
test: String,
690689
}
691690

692691
struct ClientIds {
693692
lifetimes: VecDeque<(Instant, String)>,
694-
contexts: StringHashMap<Context>,
693+
contexts: StringHashMap<TestContext>,
695694
max_lifetime: u64,
696695
}
697696

@@ -741,7 +740,7 @@ impl ClientIds {
741740
let client_id = format!("{:x}", hasher.finish());
742741
self.contexts.insert(
743742
client_id.clone(),
744-
Context {
743+
TestContext {
745744
test: "Test01".into(),
746745
},
747746
);

varlink_generator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ quote = "1.0.2"
2929
proc-macro2 = "1.0.6"
3030
getopts = "0.2.21"
3131
syn = "2.0"
32-
chainerror = "0.8.0"
32+
chainerror = "1"
3333

3434
[dev-dependencies]
3535
unified-diff = "0.2.1"

varlink_generator/src/bin/varlink-rust-generator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use std::io;
1919
use std::io::{Read, Write};
2020
use std::path::Path;
2121

22-
use chainerror::prelude::v1::*;
22+
use chainerror::Context;
2323
use varlink_generator::generate;
2424

2525
fn print_usage(program: &str, opts: &getopts::Options) {

varlink_generator/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ use std::path::{Path, PathBuf};
4040
use std::process::{exit, Command};
4141
use std::str::FromStr;
4242

43-
use chainerror::prelude::v1::*;
43+
use chainerror::Context;
4444
use proc_macro2::{Ident, Span, TokenStream};
4545
use quote::{format_ident, quote};
4646

4747
use varlink_parser::{Typedef, VEnum, VError, VStruct, VStructOrEnum, VType, VTypeExt, IDL};
4848

49-
derive_str_context!(Error);
50-
pub type Result<T> = ChainResult<T, Error>;
49+
chainerror::str_context!(Error);
50+
pub type Result<T> = chainerror::Result<T, Error>;
5151

5252
trait ToRustString<'short, 'long: 'short> {
5353
fn to_rust_string(

varlink_parser/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ travis-ci = { repository = "varlink/rust" }
2020

2121
[dependencies]
2222
colored = "2.1.0"
23-
chainerror = "0.8.0"
23+
chainerror = "1"
2424
peg = "0.6.3"

varlink_parser/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@
4444
html_favicon_url = "https://varlink.org/images/varlink-small.png"
4545
)]
4646

47+
use chainerror::Context;
48+
4749
use self::varlink_grammar::ParseInterface;
4850
use std::collections::BTreeMap;
4951
use std::collections::HashSet;
5052

51-
use chainerror::prelude::v1::*;
52-
5353
mod format;
5454

5555
pub use crate::format::{Format, FormatColored};
@@ -60,7 +60,7 @@ mod test;
6060

6161
mod varlink_grammar;
6262

63-
derive_str_context!(Error);
63+
chainerror::str_context!(Error);
6464

6565
pub enum VType<'a> {
6666
Bool,
@@ -219,13 +219,13 @@ impl<'a> IDL<'a> {
219219
}
220220

221221
#[deprecated(since = "4.1.0", note = "please use `IDL::try_from` instead")]
222-
pub fn from_string(s: &'a str) -> ChainResult<Self, Error> {
222+
pub fn from_string(s: &'a str) -> chainerror::Result<Self, Error> {
223223
IDL::try_from(s)
224224
}
225225
}
226226

227227
impl<'a> TryFrom<&'a str> for IDL<'a> {
228-
type Error = ChainError<Error>;
228+
type Error = chainerror::Error<Error>;
229229

230230
fn try_from(value: &'a str) -> Result<Self, Self::Error> {
231231
let interface = ParseInterface(value).map_context(|e| {

0 commit comments

Comments
 (0)