Skip to content

Commit bd22cba

Browse files
Merge pull request #245 from iqlusioninc/remove-failure
gaunt/subtle-encoding/tai64: Remove `failure`
2 parents 4ed9f1f + b63b98e commit bd22cba

23 files changed

+132
-145
lines changed

Cargo.lock

Lines changed: 10 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gaunt/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ keywords = ["api", "client", "http", "rest", "web"]
1515
travis-ci = { repository = "iqlusioninc/crates", branch = "develop" }
1616

1717
[dependencies]
18-
failure = { version = "0.1", default-features = false }
19-
failure_derive = "0.1"
2018
slog = { version = "2", optional = true }
2119

2220
[features]
2321
alloc = []
2422
default = ["std"]
2523
logger = ["slog", "std"]
26-
std = ["alloc", "failure/std"]
24+
std = ["alloc"]

gaunt/src/connection.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
//! Connections to HTTP servers
22
3-
use crate::prelude::*;
4-
53
#[cfg(feature = "logger")]
64
use slog::Logger;
75
use std::{
86
fmt::Write as FmtWrite,
97
io::Write,
108
net::{TcpStream, ToSocketAddrs},
119
ops::DerefMut,
10+
string::String,
1211
sync::Mutex,
1312
time::{Duration, Instant},
13+
vec::Vec,
1414
};
1515

1616
use super::{HTTP_VERSION, USER_AGENT};

gaunt/src/error.rs

Lines changed: 23 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,13 @@
22
33
#![allow(unused_macros)]
44

5-
#[cfg(feature = "alloc")]
6-
use crate::prelude::*;
5+
use core::fmt;
76

87
#[cfg(feature = "alloc")]
98
use core::{num::ParseIntError, str::Utf8Error};
10-
use failure::Context;
119

1210
#[cfg(feature = "std")]
1311
use std::{
14-
error::Error as StdError,
15-
fmt::{self, Display},
1612
io,
1713
string::{FromUtf8Error, String, ToString},
1814
};
@@ -21,7 +17,7 @@ use std::{
2117
#[derive(Debug)]
2218
pub struct Error {
2319
/// Error context and kind
24-
inner: Context<ErrorKind>,
20+
kind: ErrorKind,
2521

2622
/// Optional description
2723
#[cfg(feature = "alloc")]
@@ -45,72 +41,62 @@ impl Error {
4541

4642
/// Obtain the inner `ErrorKind` for this `Error`
4743
pub fn kind(&self) -> ErrorKind {
48-
*self.inner.get_context()
44+
self.kind
4945
}
5046
}
5147

52-
#[cfg(feature = "alloc")]
53-
impl Display for Error {
48+
impl fmt::Display for Error {
5449
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
55-
self.description().fmt(f)
50+
self.kind.fmt(f)
5651
}
5752
}
5853

59-
#[cfg(feature = "alloc")]
60-
impl StdError for Error {
61-
fn description(&self) -> &str {
62-
if let Some(ref desc) = self.description {
63-
desc
64-
} else {
65-
"(none)"
66-
}
67-
}
68-
}
54+
#[cfg(feature = "std")]
55+
impl std::error::Error for Error {}
6956

7057
impl From<ErrorKind> for Error {
7158
fn from(kind: ErrorKind) -> Error {
7259
Error {
73-
inner: Context::new(kind),
74-
#[cfg(feature = "alloc")]
75-
description: None,
76-
}
77-
}
78-
}
79-
80-
impl From<Context<ErrorKind>> for Error {
81-
fn from(inner: Context<ErrorKind>) -> Self {
82-
Self {
83-
inner,
60+
kind,
8461
#[cfg(feature = "alloc")]
8562
description: None,
8663
}
8764
}
8865
}
8966

9067
/// Kinds of errors
91-
#[derive(Copy, Clone, Debug, Fail, Eq, PartialEq)]
68+
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
9269
pub enum ErrorKind {
9370
/// Invalid address
94-
#[fail(display = "address invalid")]
9571
AddrInvalid,
9672

9773
/// I/O operation failed
98-
#[fail(display = "I/O error")]
9974
IoError,
10075

10176
/// Parsing data failed
102-
#[fail(display = "parse error")]
10377
ParseError,
10478

10579
/// Request failed
106-
#[fail(display = "request error")]
10780
RequestError,
10881

10982
/// Error reading response
110-
#[fail(display = "error reading response")]
11183
ResponseError,
11284
}
11385

86+
impl fmt::Display for ErrorKind {
87+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
88+
let description = match self {
89+
ErrorKind::AddrInvalid => "address invalid",
90+
ErrorKind::IoError => "I/O error",
91+
ErrorKind::ParseError => "parse error",
92+
ErrorKind::RequestError => "request error",
93+
ErrorKind::ResponseError => "error reading response",
94+
};
95+
96+
write!(f, "{}", description)
97+
}
98+
}
99+
114100
/// Create a new error (of a given enum variant) with a formatted message
115101
macro_rules! err {
116102
($variant:ident, $msg:expr) => {

gaunt/src/lib.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
//! **gaunt.rs**: high-level, self-contained, minimalist HTTP toolkit.
22
3-
#![crate_name = "gaunt"]
4-
#![crate_type = "rlib"]
5-
#![deny(warnings, missing_docs, unused_import_braces, unused_qualifications)]
63
#![no_std]
7-
#![cfg_attr(all(feature = "nightly", not(feature = "std")), feature(alloc))]
4+
#![deny(warnings, missing_docs, unused_import_braces, unused_qualifications)]
85
#![forbid(unsafe_code)]
96
#![doc(
107
html_logo_url = "https://storage.googleapis.com/iqlusion-production-web/github/gaunt/gaunt-logo.svg",
118
html_root_url = "https://docs.rs/gaunt/0.1.0"
129
)]
1310

11+
#[cfg(feature = "alloc")]
12+
extern crate alloc;
13+
1414
#[cfg(any(feature = "std", test))]
1515
#[macro_use]
1616
extern crate std;
1717

18-
extern crate failure;
19-
#[macro_use]
20-
extern crate failure_derive;
2118
#[cfg(feature = "logger")]
2219
#[macro_use]
2320
extern crate slog;
@@ -28,7 +25,6 @@ pub mod error;
2825
#[cfg(feature = "std")]
2926
pub mod connection;
3027
pub mod path;
31-
pub mod prelude;
3228
#[cfg(feature = "alloc")]
3329
pub mod request;
3430
#[cfg(feature = "alloc")]

gaunt/src/path.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
33
#[cfg(feature = "alloc")]
44
use {
5-
crate::{error::Error, prelude::*},
5+
crate::error::Error,
6+
alloc::{borrow::ToOwned, string::String},
67
core::{
78
fmt::{self, Display},
89
str::FromStr,

gaunt/src/prelude.rs

Lines changed: 0 additions & 7 deletions
This file was deleted.

gaunt/src/request.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! HTTP request types
22
3-
use crate::prelude::*;
3+
use alloc::vec::Vec;
44

55
/// Request bodies
66
#[derive(Debug, Default)]

gaunt/src/response/body.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Response body types.
22
// TODO: support for streaming response bodies
33

4-
use crate::prelude::*;
4+
use alloc::vec::Vec;
55

66
/// Response body
77
#[derive(Debug)]

gaunt/src/response/reader.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
//! Read HTTP responses from an `io::Read`
22
3-
use crate::prelude::*;
4-
5-
use std::{io::Read, str};
3+
use std::{io::Read, str, vec::Vec};
64

75
use super::Body;
86
use crate::error::Error;

subtle-encoding/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ categories = ["cryptography", "encoding", "no-std"]
1717
keywords = ["base64", "bech32", "constant-time", "hex", "security"]
1818

1919
[dependencies]
20-
failure = { version = "0.1", default-features = false }
21-
failure_derive = "0.1"
2220
zeroize = { version = "0.9", default-features = false, optional = true, path = "../zeroize" }
2321

2422
[features]

subtle-encoding/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Crate][crate-image]][crate-link]
44
[![Docs][docs-image]][docs-link]
55
![Apache 2.0/MIT Licensed][license-image]
6-
![Rust 1.35+][rustc-image]
6+
![MSRV][rustc-image]
77
[![Safety Dance][safety-image]][safety-link]
88
[![Build Status][build-image]][build-link]
99
[![Gitter Chat][gitter-image]][gitter-link]
@@ -18,7 +18,7 @@ Useful for encoding/decoding secret values such as cryptographic keys.
1818

1919
## Requirements
2020

21-
- Rust 1.35+
21+
- Rust **1.36+**
2222

2323
## Security Notice
2424

@@ -48,7 +48,7 @@ toplevel directory of this repository or [LICENSE-MIT] for details.
4848
[docs-image]: https://docs.rs/subtle-encoding/badge.svg
4949
[docs-link]: https://docs.rs/subtle-encoding/
5050
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
51-
[rustc-image]: https://img.shields.io/badge/rustc-1.35+-blue.svg
51+
[rustc-image]: https://img.shields.io/badge/rustc-1.36+-blue.svg
5252
[safety-image]: https://img.shields.io/badge/unsafe-forbidden-success.svg
5353
[safety-link]: https://github.com/rust-secure-code/safety-dance/
5454
[build-image]: https://travis-ci.com/iqlusioninc/crates.svg?branch=develop

subtle-encoding/src/base64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use super::{
1212
Error::{self, *},
1313
};
1414
#[cfg(feature = "alloc")]
15-
use crate::prelude::*;
15+
use alloc::vec::Vec;
1616
use zeroize::Zeroize;
1717

1818
/// Base64 `Encoding` (traditional non-URL-safe RFC 4648 version)

0 commit comments

Comments
 (0)