Skip to content

gaunt/subtle-encoding/tai64: Remove failure #245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 10 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions gaunt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ keywords = ["api", "client", "http", "rest", "web"]
travis-ci = { repository = "iqlusioninc/crates", branch = "develop" }

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

[features]
alloc = []
default = ["std"]
logger = ["slog", "std"]
std = ["alloc", "failure/std"]
std = ["alloc"]
4 changes: 2 additions & 2 deletions gaunt/src/connection.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
//! Connections to HTTP servers

use crate::prelude::*;

#[cfg(feature = "logger")]
use slog::Logger;
use std::{
fmt::Write as FmtWrite,
io::Write,
net::{TcpStream, ToSocketAddrs},
ops::DerefMut,
string::String,
sync::Mutex,
time::{Duration, Instant},
vec::Vec,
};

use super::{HTTP_VERSION, USER_AGENT};
Expand Down
60 changes: 23 additions & 37 deletions gaunt/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@

#![allow(unused_macros)]

#[cfg(feature = "alloc")]
use crate::prelude::*;
use core::fmt;

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

#[cfg(feature = "std")]
use std::{
error::Error as StdError,
fmt::{self, Display},
io,
string::{FromUtf8Error, String, ToString},
};
Expand All @@ -21,7 +17,7 @@ use std::{
#[derive(Debug)]
pub struct Error {
/// Error context and kind
inner: Context<ErrorKind>,
kind: ErrorKind,

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

/// Obtain the inner `ErrorKind` for this `Error`
pub fn kind(&self) -> ErrorKind {
*self.inner.get_context()
self.kind
}
}

#[cfg(feature = "alloc")]
impl Display for Error {
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.description().fmt(f)
self.kind.fmt(f)
}
}

#[cfg(feature = "alloc")]
impl StdError for Error {
fn description(&self) -> &str {
if let Some(ref desc) = self.description {
desc
} else {
"(none)"
}
}
}
#[cfg(feature = "std")]
impl std::error::Error for Error {}

impl From<ErrorKind> for Error {
fn from(kind: ErrorKind) -> Error {
Error {
inner: Context::new(kind),
#[cfg(feature = "alloc")]
description: None,
}
}
}

impl From<Context<ErrorKind>> for Error {
fn from(inner: Context<ErrorKind>) -> Self {
Self {
inner,
kind,
#[cfg(feature = "alloc")]
description: None,
}
}
}

/// Kinds of errors
#[derive(Copy, Clone, Debug, Fail, Eq, PartialEq)]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum ErrorKind {
/// Invalid address
#[fail(display = "address invalid")]
AddrInvalid,

/// I/O operation failed
#[fail(display = "I/O error")]
IoError,

/// Parsing data failed
#[fail(display = "parse error")]
ParseError,

/// Request failed
#[fail(display = "request error")]
RequestError,

/// Error reading response
#[fail(display = "error reading response")]
ResponseError,
}

impl fmt::Display for ErrorKind {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let description = match self {
ErrorKind::AddrInvalid => "address invalid",
ErrorKind::IoError => "I/O error",
ErrorKind::ParseError => "parse error",
ErrorKind::RequestError => "request error",
ErrorKind::ResponseError => "error reading response",
};

write!(f, "{}", description)
}
}

/// Create a new error (of a given enum variant) with a formatted message
macro_rules! err {
($variant:ident, $msg:expr) => {
Expand Down
12 changes: 4 additions & 8 deletions gaunt/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
//! **gaunt.rs**: high-level, self-contained, minimalist HTTP toolkit.

#![crate_name = "gaunt"]
#![crate_type = "rlib"]
#![deny(warnings, missing_docs, unused_import_braces, unused_qualifications)]
#![no_std]
#![cfg_attr(all(feature = "nightly", not(feature = "std")), feature(alloc))]
#![deny(warnings, missing_docs, unused_import_braces, unused_qualifications)]
#![forbid(unsafe_code)]
#![doc(
html_logo_url = "https://storage.googleapis.com/iqlusion-production-web/github/gaunt/gaunt-logo.svg",
html_root_url = "https://docs.rs/gaunt/0.1.0"
)]

#[cfg(feature = "alloc")]
extern crate alloc;

#[cfg(any(feature = "std", test))]
#[macro_use]
extern crate std;

extern crate failure;
#[macro_use]
extern crate failure_derive;
#[cfg(feature = "logger")]
#[macro_use]
extern crate slog;
Expand All @@ -28,7 +25,6 @@ pub mod error;
#[cfg(feature = "std")]
pub mod connection;
pub mod path;
pub mod prelude;
#[cfg(feature = "alloc")]
pub mod request;
#[cfg(feature = "alloc")]
Expand Down
3 changes: 2 additions & 1 deletion gaunt/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

#[cfg(feature = "alloc")]
use {
crate::{error::Error, prelude::*},
crate::error::Error,
alloc::{borrow::ToOwned, string::String},
core::{
fmt::{self, Display},
str::FromStr,
Expand Down
7 changes: 0 additions & 7 deletions gaunt/src/prelude.rs

This file was deleted.

2 changes: 1 addition & 1 deletion gaunt/src/request.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! HTTP request types

use crate::prelude::*;
use alloc::vec::Vec;

/// Request bodies
#[derive(Debug, Default)]
Expand Down
2 changes: 1 addition & 1 deletion gaunt/src/response/body.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Response body types.
// TODO: support for streaming response bodies

use crate::prelude::*;
use alloc::vec::Vec;

/// Response body
#[derive(Debug)]
Expand Down
4 changes: 1 addition & 3 deletions gaunt/src/response/reader.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! Read HTTP responses from an `io::Read`

use crate::prelude::*;

use std::{io::Read, str};
use std::{io::Read, str, vec::Vec};

use super::Body;
use crate::error::Error;
Expand Down
2 changes: 0 additions & 2 deletions subtle-encoding/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ categories = ["cryptography", "encoding", "no-std"]
keywords = ["base64", "bech32", "constant-time", "hex", "security"]

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

[features]
Expand Down
6 changes: 3 additions & 3 deletions subtle-encoding/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Crate][crate-image]][crate-link]
[![Docs][docs-image]][docs-link]
![Apache 2.0/MIT Licensed][license-image]
![Rust 1.35+][rustc-image]
![MSRV][rustc-image]
[![Safety Dance][safety-image]][safety-link]
[![Build Status][build-image]][build-link]
[![Gitter Chat][gitter-image]][gitter-link]
Expand All @@ -18,7 +18,7 @@ Useful for encoding/decoding secret values such as cryptographic keys.

## Requirements

- Rust 1.35+
- Rust **1.36+**

## Security Notice

Expand Down Expand Up @@ -48,7 +48,7 @@ toplevel directory of this repository or [LICENSE-MIT] for details.
[docs-image]: https://docs.rs/subtle-encoding/badge.svg
[docs-link]: https://docs.rs/subtle-encoding/
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
[rustc-image]: https://img.shields.io/badge/rustc-1.35+-blue.svg
[rustc-image]: https://img.shields.io/badge/rustc-1.36+-blue.svg
[safety-image]: https://img.shields.io/badge/unsafe-forbidden-success.svg
[safety-link]: https://github.com/rust-secure-code/safety-dance/
[build-image]: https://travis-ci.com/iqlusioninc/crates.svg?branch=develop
Expand Down
2 changes: 1 addition & 1 deletion subtle-encoding/src/base64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use super::{
Error::{self, *},
};
#[cfg(feature = "alloc")]
use crate::prelude::*;
use alloc::vec::Vec;
use zeroize::Zeroize;

/// Base64 `Encoding` (traditional non-URL-safe RFC 4648 version)
Expand Down
Loading