Prepare for Rust 2018.

  - This is the result of running `cargo fix --edition`, with some
    manual adjustments.

  - The vast majority of changes merely qualify module paths with
    'crate::'.

  - Two instances of adding an anonymous pattern to a trait's
    function.

  - `async` is a keyword in Rust 2018, and hence it needs to be
    escaped (e.g. in the case of the net::r#async module).

  - The manual adjustments were needed due to various shortcomings of
    the analysis employed by `cargo fix`, e.g. unexpanded macros,
    procedural macros, lalrpop grammars.
parent caec575e
......@@ -2,7 +2,7 @@ use std::io;
use std::io::{Error, ErrorKind, Read};
use std::fmt;
use BufferedReader;
use crate::BufferedReader;
/// Always returns EOF.
pub struct EOF<C> {
......
......@@ -160,7 +160,7 @@ mod test {
#[test]
fn data() {
use ::Memory;
use crate::Memory;
// orig is the original buffer
//
......
//! https://sequoia-pgp.org/guide/exploring-openpgp/
extern crate sequoia_openpgp as openpgp;
use openpgp::parse::Parse;
use crate::openpgp::parse::Parse;
fn main() {
let tpk =
......
......@@ -3,7 +3,7 @@
extern crate sequoia_openpgp as openpgp;
extern crate sequoia;
use sequoia::{core, store};
use openpgp::parse::Parse;
use crate::openpgp::parse::Parse;
fn main() {
let tpk =
......
This diff is collapsed.
......@@ -48,7 +48,7 @@ use sequoia_core::Config;
#[doc(hidden)]
pub struct Context {
pub(crate) c: core::Context,
e: *mut ::error::Error,
e: *mut crate::error::Error,
}
impl Context {
......@@ -56,7 +56,7 @@ impl Context {
Context{c: c, e: ptr::null_mut()}
}
pub(crate) fn errp(&mut self) -> &mut *mut ::error::Error {
pub(crate) fn errp(&mut self) -> &mut *mut crate::error::Error {
&mut self.e
}
}
......@@ -64,8 +64,8 @@ impl Context {
/// Returns the last error.
///
/// Returns and removes the last error from the context.
#[::ffi_catch_abort] #[no_mangle] pub extern "C"
fn sq_context_last_error(ctx: *mut Context) -> *mut ::error::Error {
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn sq_context_last_error(ctx: *mut Context) -> *mut crate::error::Error {
let ctx = ffi_param_ref_mut!(ctx);
::std::mem::replace(&mut ctx.e, ptr::null_mut())
}
......@@ -74,15 +74,15 @@ fn sq_context_last_error(ctx: *mut Context) -> *mut ::error::Error {
///
/// Returns `NULL` on errors. If `errp` is not `NULL`, the error is
/// stored there.
#[::ffi_catch_abort] #[no_mangle] pub extern "C"
fn sq_context_new(errp: Option<&mut *mut ::error::Error>)
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn sq_context_new(errp: Option<&mut *mut crate::error::Error>)
-> *mut Context {
ffi_make_fry_from_errp!(errp);
ffi_try_box!(core::Context::new().map(|ctx| Context::new(ctx)))
}
/// Frees a context.
#[::ffi_catch_abort] #[no_mangle] pub extern "C"
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn sq_context_free(context: Option<&mut Context>) {
ffi_free!(context)
}
......@@ -92,41 +92,41 @@ fn sq_context_free(context: Option<&mut Context>) {
/// The configuration is seeded like in `sq_context_new`, but can be
/// modified. A configuration has to be finalized using
/// `sq_config_build()` in order to turn it into a Context.
#[::ffi_catch_abort] #[no_mangle] pub extern "C"
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn sq_context_configure() -> *mut Config {
Box::into_raw(Box::new(core::Context::configure()))
}
/// Returns the directory containing shared state.
#[::ffi_catch_abort] #[no_mangle] pub extern "C"
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn sq_context_home(ctx: *const Context) -> *const c_char {
let ctx = ffi_param_ref!(ctx);
ctx.c.home().to_string_lossy().as_ptr() as *const c_char
}
/// Returns the directory containing backend servers.
#[::ffi_catch_abort] #[no_mangle] pub extern "C"
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn sq_context_lib(ctx: *const Context) -> *const c_char {
let ctx = ffi_param_ref!(ctx);
ctx.c.lib().to_string_lossy().as_bytes().as_ptr() as *const c_char
}
/// Returns the network policy.
#[::ffi_catch_abort] #[no_mangle] pub extern "C"
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn sq_context_network_policy(ctx: *const Context) -> c_int {
let ctx = ffi_param_ref!(ctx);
u8::from(ctx.c.network_policy()) as c_int
}
/// Returns the IPC policy.
#[::ffi_catch_abort] #[no_mangle] pub extern "C"
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn sq_context_ipc_policy(ctx: *const Context) -> c_int {
let ctx = ffi_param_ref!(ctx);
u8::from(ctx.c.ipc_policy()) as c_int
}
/// Returns whether or not this is an ephemeral context.
#[::ffi_catch_abort] #[no_mangle] pub extern "C"
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn sq_context_ephemeral(ctx: *const Context) -> u8 {
let ctx = ffi_param_ref!(ctx);
if ctx.c.ephemeral() { 1 } else { 0 }
......@@ -139,8 +139,8 @@ fn sq_context_ephemeral(ctx: *const Context) -> u8 {
///
/// Consumes `cfg`. Returns `NULL` on errors. Returns `NULL` on
/// errors. If `errp` is not `NULL`, the error is stored there.
#[::ffi_catch_abort] #[no_mangle] pub extern "C"
fn sq_config_build(cfg: *mut Config, errp: Option<&mut *mut ::error::Error>)
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn sq_config_build(cfg: *mut Config, errp: Option<&mut *mut crate::error::Error>)
-> *mut Context {
ffi_make_fry_from_errp!(errp);
let cfg = ffi_param_move!(cfg);
......@@ -149,7 +149,7 @@ fn sq_config_build(cfg: *mut Config, errp: Option<&mut *mut ::error::Error>)
}
/// Sets the directory containing shared state.
#[::ffi_catch_abort] #[no_mangle] pub extern "C"
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn sq_config_home(cfg: *mut Config, home: *const c_char) {
let cfg = ffi_param_ref_mut!(cfg);
let home = ffi_param_cstr!(home).to_string_lossy();
......@@ -157,7 +157,7 @@ fn sq_config_home(cfg: *mut Config, home: *const c_char) {
}
/// Set the directory containing backend servers.
#[::ffi_catch_abort] #[no_mangle] pub extern "C"
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn sq_config_lib(cfg: *mut Config, lib: *const c_char) {
let cfg = ffi_param_ref_mut!(cfg);
let lib = ffi_param_cstr!(lib).to_string_lossy();
......@@ -165,7 +165,7 @@ fn sq_config_lib(cfg: *mut Config, lib: *const c_char) {
}
/// Sets the network policy.
#[::ffi_catch_abort] #[no_mangle] pub extern "C"
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn sq_config_network_policy(cfg: *mut Config, policy: c_int) {
let cfg = ffi_param_ref_mut!(cfg);
if policy < 0 || policy > 3 {
......@@ -175,7 +175,7 @@ fn sq_config_network_policy(cfg: *mut Config, policy: c_int) {
}
/// Sets the IPC policy.
#[::ffi_catch_abort] #[no_mangle] pub extern "C"
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn sq_config_ipc_policy(cfg: *mut Config, policy: c_int) {
let cfg = ffi_param_ref_mut!(cfg);
if policy < 0 || policy > 2 {
......@@ -185,7 +185,7 @@ fn sq_config_ipc_policy(cfg: *mut Config, policy: c_int) {
}
/// Makes this context ephemeral.
#[::ffi_catch_abort] #[no_mangle] pub extern "C"
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn sq_config_ephemeral(cfg: *mut Config) {
let cfg = ffi_param_ref_mut!(cfg);
cfg.set_ephemeral();
......
......@@ -5,12 +5,12 @@ use std::io;
extern crate sequoia_openpgp as openpgp;
use sequoia_core as core;
pub use openpgp::error::Status;
pub use crate::openpgp::error::Status;
pub(crate) use ::openpgp::error::Error;
pub(crate) use crate::openpgp::error::Error;
trait FromSequoiaError<'a> {
fn from_sequoia_error(&'a failure::Error) -> Status;
fn from_sequoia_error(_: &'a failure::Error) -> Status;
}
impl<'a> FromSequoiaError<'a> for Status {
......
......@@ -117,7 +117,6 @@ extern crate nettle;
extern crate sequoia_ffi_macros;
use sequoia_ffi_macros::{
ffi_catch_abort,
ffi_wrapper_type,
};
extern crate sequoia_openpgp;
......@@ -131,7 +130,7 @@ pub mod openpgp {
include!("../../openpgp-ffi/src/common.rs");
}
pub(crate) use openpgp::{
pub(crate) use crate::openpgp::{
io,
build_hasher,
strndup,
......
......@@ -38,11 +38,11 @@ use sequoia_net::KeyServer;
use super::error::Status;
use super::core::Context;
use ::openpgp::keyid::KeyID;
use ::openpgp::tpk::TPK;
use ::RefRaw;
use MoveResultIntoRaw;
use Maybe;
use crate::openpgp::keyid::KeyID;
use crate::openpgp::tpk::TPK;
use crate::RefRaw;
use crate::MoveResultIntoRaw;
use crate::Maybe;
/// Returns a handle for the given URI.
///
......@@ -50,7 +50,7 @@ use Maybe;
/// e.g. `hkps://examle.org`.
///
/// Returns `NULL` on errors.
#[::ffi_catch_abort] #[no_mangle] pub extern "C"
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn sq_keyserver_new(ctx: *mut Context, uri: *const c_char) -> *mut KeyServer {
let ctx = ffi_param_ref_mut!(ctx);
ffi_make_fry_from_ctx!(ctx);
......@@ -66,7 +66,7 @@ fn sq_keyserver_new(ctx: *mut Context, uri: *const c_char) -> *mut KeyServer {
/// size `len` used to authenticate the server.
///
/// Returns `NULL` on errors.
#[::ffi_catch_abort] #[no_mangle] pub extern "C"
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn sq_keyserver_with_cert(ctx: *mut Context,
uri: *const c_char,
cert: *const u8,
......@@ -95,7 +95,7 @@ fn sq_keyserver_with_cert(ctx: *mut Context,
/// included in this library. It is a good default choice.
///
/// Returns `NULL` on errors.
#[::ffi_catch_abort] #[no_mangle] pub extern "C"
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn sq_keyserver_sks_pool(ctx: *mut Context) -> *mut KeyServer {
let ctx = ffi_param_ref_mut!(ctx);
ffi_make_fry_from_ctx!(ctx);
......@@ -103,7 +103,7 @@ fn sq_keyserver_sks_pool(ctx: *mut Context) -> *mut KeyServer {
}
/// Frees a keyserver object.
#[::ffi_catch_abort] #[no_mangle] pub extern "C"
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn sq_keyserver_free(ks: Option<&mut KeyServer>) {
ffi_free!(ks)
}
......@@ -111,7 +111,7 @@ fn sq_keyserver_free(ks: Option<&mut KeyServer>) {
/// Retrieves the key with the given `keyid`.
///
/// Returns `NULL` on errors.
#[::ffi_catch_abort] #[no_mangle] pub extern "C"
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn sq_keyserver_get(ctx: *mut Context,
ks: *mut KeyServer,
id: *const KeyID)
......@@ -127,7 +127,7 @@ fn sq_keyserver_get(ctx: *mut Context,
/// Sends the given key to the server.
///
/// Returns != 0 on errors.
#[::ffi_catch_abort] #[no_mangle] pub extern "C"
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn sq_keyserver_send(ctx: *mut Context,
ks: *mut KeyServer,
tpk: *const TPK)
......
This diff is collapsed.
......@@ -3,7 +3,7 @@ use futures::future::Future;
use futures::stream::Stream;
extern crate clap;
extern crate sequoia_ipc as ipc;
use ipc::assuan::Client;
use crate::ipc::assuan::Client;
fn main() {
let matches = clap::App::new("assuan-client")
......
......@@ -5,7 +5,7 @@ use futures::future::Future;
use futures::stream::Stream;
extern crate clap;
extern crate sequoia_ipc as ipc;
use ipc::gnupg::{Context, Agent};
use crate::ipc::gnupg::{Context, Agent};
fn main() {
let matches = clap::App::new("gpg-agent-client")
......
......@@ -7,9 +7,9 @@ extern crate clap;
extern crate sequoia_openpgp as openpgp;
extern crate sequoia_ipc as ipc;
use openpgp::crypto::SessionKey;
use openpgp::constants::SymmetricAlgorithm;
use openpgp::parse::{
use crate::openpgp::crypto::SessionKey;
use crate::openpgp::constants::SymmetricAlgorithm;
use crate::openpgp::parse::{
Parse,
stream::{
DecryptionHelper,
......@@ -20,7 +20,7 @@ use openpgp::parse::{
MessageLayer,
},
};
use ipc::gnupg::{Context, KeyPair};
use crate::ipc::gnupg::{Context, KeyPair};
fn main() {
let matches = clap::App::new("gpg-agent-decrypt")
......
......@@ -6,11 +6,11 @@ extern crate clap;
extern crate sequoia_openpgp as openpgp;
extern crate sequoia_ipc as ipc;
use openpgp::armor;
use openpgp::constants::DataFormat;
use openpgp::parse::Parse;
use openpgp::serialize::stream::{Message, LiteralWriter, Signer};
use ipc::gnupg::{Context, KeyPair};
use crate::openpgp::armor;
use crate::openpgp::constants::DataFormat;
use crate::openpgp::parse::Parse;
use crate::openpgp::serialize::stream::{Message, LiteralWriter, Signer};
use crate::ipc::gnupg::{Context, KeyPair};
fn main() {
let matches = clap::App::new("gpg-agent-sign")
......
......@@ -5,7 +5,7 @@
//
// [S-Expressions]: https://people.csail.mit.edu/rivest/Sexp.txt
use assuan::{
use crate::assuan::{
Response,
lexer::{self, LexicalError},
};
......
......@@ -14,10 +14,10 @@ use tokio::net::UnixStream;
use tokio_io::io;
use tokio_io::AsyncRead;
use openpgp;
use crate::openpgp;
use Error;
use Result;
use crate::Error;
use crate::Result;
mod lexer;
......
......@@ -12,15 +12,15 @@ use futures::{Async, Future, Stream};
extern crate libc;
extern crate tempfile;
use openpgp::constants::HashAlgorithm;
use openpgp::conversions::hex;
use openpgp::crypto;
use openpgp::crypto::sexp::Sexp;
use openpgp::parse::Parse;
use openpgp::serialize::Serialize;
use crate::openpgp::constants::HashAlgorithm;
use crate::openpgp::conversions::hex;
use crate::openpgp::crypto;
use crate::openpgp::crypto::sexp::Sexp;
use crate::openpgp::parse::Parse;
use crate::openpgp::serialize::Serialize;
use Result;
use assuan;
use crate::Result;
use crate::assuan;
/// A GnuPG context.
#[derive(Debug)]
......@@ -696,8 +696,8 @@ impl<'a> crypto::Signer for KeyPair<'a> {
fn sign(&mut self, hash_algo: HashAlgorithm, digest: &[u8])
-> Result<openpgp::crypto::mpis::Signature>
{
use openpgp::constants::PublicKeyAlgorithm::*;
use openpgp::crypto::mpis::PublicKey;
use crate::openpgp::constants::PublicKeyAlgorithm::*;
use crate::openpgp::crypto::mpis::PublicKey;
#[allow(deprecated)]
match (self.public.pk_algo(), self.public.mpis())
......@@ -727,7 +727,7 @@ impl<'a> crypto::Decryptor for KeyPair<'a> {
fn decrypt(&mut self, ciphertext: &crypto::mpis::Ciphertext)
-> Result<crypto::SessionKey>
{
use openpgp::crypto::mpis::{PublicKey, Ciphertext};
use crate::openpgp::crypto::mpis::{PublicKey, Ciphertext};
match (self.public.mpis(), ciphertext) {
(PublicKey::RSA { .. }, Ciphertext::RSA { .. })
......
......@@ -35,29 +35,29 @@ macro_rules! tracer {
// https://users.rust-lang.org/t/nested-macros-issue/8348/2
macro_rules! t {
( $fmt:expr ) =>
{ trace!($TRACE, "{}{}: {}", ::trace::indent($indent as usize), $func, $fmt) };
{ trace!($TRACE, "{}{}: {}", crate::trace::indent($indent as usize), $func, $fmt) };
( $fmt:expr, $a:expr ) =>
{ trace!($TRACE, "{}{}: {}", ::trace::indent($indent as usize), $func, format!($fmt, $a)) };
{ trace!($TRACE, "{}{}: {}", crate::trace::indent($indent as usize), $func, format!($fmt, $a)) };
( $fmt:expr, $a:expr, $b:expr ) =>
{ trace!($TRACE, "{}{}: {}", ::trace::indent($indent as usize), $func, format!($fmt, $a, $b)) };
{ trace!($TRACE, "{}{}: {}", crate::trace::indent($indent as usize), $func, format!($fmt, $a, $b)) };
( $fmt:expr, $a:expr, $b:expr, $c:expr ) =>
{ trace!($TRACE, "{}{}: {}", ::trace::indent($indent as usize), $func, format!($fmt, $a, $b, $c)) };
{ trace!($TRACE, "{}{}: {}", crate::trace::indent($indent as usize), $func, format!($fmt, $a, $b, $c)) };
( $fmt:expr, $a:expr, $b:expr, $c:expr, $d:expr ) =>
{ trace!($TRACE, "{}{}: {}", ::trace::indent($indent as usize), $func, format!($fmt, $a, $b, $c, $d)) };
{ trace!($TRACE, "{}{}: {}", crate::trace::indent($indent as usize), $func, format!($fmt, $a, $b, $c, $d)) };
( $fmt:expr, $a:expr, $b:expr, $c:expr, $d:expr, $e:expr ) =>
{ trace!($TRACE, "{}{}: {}", ::trace::indent($indent as usize), $func, format!($fmt, $a, $b, $c, $d, $e)) };
{ trace!($TRACE, "{}{}: {}", crate::trace::indent($indent as usize), $func, format!($fmt, $a, $b, $c, $d, $e)) };
( $fmt:expr, $a:expr, $b:expr, $c:expr, $d:expr, $e:expr, $f:expr ) =>
{ trace!($TRACE, "{}{}: {}", ::trace::indent($indent as usize), $func, format!($fmt, $a, $b, $c, $d, $e, $f)) };
{ trace!($TRACE, "{}{}: {}", crate::trace::indent($indent as usize), $func, format!($fmt, $a, $b, $c, $d, $e, $f)) };
( $fmt:expr, $a:expr, $b:expr, $c:expr, $d:expr, $e:expr, $f:expr, $g:expr ) =>
{ trace!($TRACE, "{}{}: {}", ::trace::indent($indent as usize), $func, format!($fmt, $a, $b, $c, $d, $e, $f, $g)) };
{ trace!($TRACE, "{}{}: {}", crate::trace::indent($indent as usize), $func, format!($fmt, $a, $b, $c, $d, $e, $f, $g)) };
( $fmt:expr, $a:expr, $b:expr, $c:expr, $d:expr, $e:expr, $f:expr, $g:expr, $h:expr ) =>
{ trace!($TRACE, "{}{}: {}", ::trace::indent($indent as usize), $func, format!($fmt, $a, $b, $c, $d, $e, $f, $g, $h)) };
{ trace!($TRACE, "{}{}: {}", crate::trace::indent($indent as usize), $func, format!($fmt, $a, $b, $c, $d, $e, $f, $g, $h)) };
( $fmt:expr, $a:expr, $b:expr, $c:expr, $d:expr, $e:expr, $f:expr, $g:expr, $h:expr, $i:expr ) =>
{ trace!($TRACE, "{}{}: {}", ::trace::indent($indent as usize), $func, format!($fmt, $a, $b, $c, $d, $e, $f, $g, $h, $i)) };
{ trace!($TRACE, "{}{}: {}", crate::trace::indent($indent as usize), $func, format!($fmt, $a, $b, $c, $d, $e, $f, $g, $h, $i)) };
( $fmt:expr, $a:expr, $b:expr, $c:expr, $d:expr, $e:expr, $f:expr, $g:expr, $h:expr, $i:expr, $j:expr ) =>
{ trace!($TRACE, "{}{}: {}", ::trace::indent($indent as usize), $func, format!($fmt, $a, $b, $c, $d, $e, $f, $g, $h, $i, $j)) };
{ trace!($TRACE, "{}{}: {}", crate::trace::indent($indent as usize), $func, format!($fmt, $a, $b, $c, $d, $e, $f, $g, $h, $i, $j)) };
( $fmt:expr, $a:expr, $b:expr, $c:expr, $d:expr, $e:expr, $f:expr, $g:expr, $h:expr, $i:expr, $j:expr, $k:expr ) =>
{ trace!($TRACE, "{}{}: {}", ::trace::indent($indent as usize), $func, format!($fmt, $a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k)) };
{ trace!($TRACE, "{}{}: {}", crate::trace::indent($indent as usize), $func, format!($fmt, $a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k)) };
}
};
}
......@@ -7,15 +7,15 @@ use futures::future::Future;
use futures::stream::Stream;
extern crate sequoia_openpgp as openpgp;
use openpgp::constants::SymmetricAlgorithm;
use openpgp::crypto::SessionKey;
use openpgp::packet::KeyFlags;
use openpgp::parse::stream::*;
use openpgp::serialize::{Serialize, stream::*};
use openpgp::tpk::{TPKBuilder, CipherSuite};
use crate::openpgp::constants::SymmetricAlgorithm;
use crate::openpgp::crypto::SessionKey;
use crate::openpgp::packet::KeyFlags;
use crate::openpgp::parse::stream::*;
use crate::openpgp::serialize::{Serialize, stream::*};
use crate::openpgp::tpk::{TPKBuilder, CipherSuite};
extern crate sequoia_ipc as ipc;
use ipc::gnupg::{Context, Agent, KeyPair};
use crate::ipc::gnupg::{Context, Agent, KeyPair};
macro_rules! make_context {
() => {{
......
......@@ -15,12 +15,12 @@ use std::convert::From;
use std::io::Cursor;
use url::Url;
use openpgp::TPK;
use openpgp::parse::Parse;
use openpgp::{KeyID, armor, serialize::Serialize};
use crate::openpgp::TPK;
use crate::openpgp::parse::Parse;
use crate::openpgp::{KeyID, armor, serialize::Serialize};
use sequoia_core::{Context, NetworkPolicy};
use wkd as net_wkd;
use crate::wkd as net_wkd;
use super::{Error, Result};
......@@ -148,7 +148,7 @@ impl KeyServer {
/// Sends the given key to the server.
pub fn send(&mut self, key: &TPK)
-> Box<Future<Item=(), Error=failure::Error> + 'static> {
use openpgp::armor::{Writer, Kind};
use crate::openpgp::armor::{Writer, Kind};
let uri =
match self.uri.join("pks/add") {
......
......@@ -59,25 +59,25 @@ use std::convert::From;
use tokio_core::reactor::Core;
use url::Url;
use openpgp::KeyID;
use openpgp::TPK;
use crate::openpgp::KeyID;
use crate::openpgp::TPK;
use sequoia_core::Context;
pub mod async;
use async::url2uri;
pub mod r#async;
use crate::r#async::url2uri;
pub mod wkd;
/// For accessing keyservers using HKP.
pub struct KeyServer {
core: Core,
ks: async::KeyServer,
ks: r#async::KeyServer,
}
impl KeyServer {
/// Returns a handle for the given URI.
pub fn new(ctx: &Context, uri: &str) -> Result<Self> {
let core = Core::new()?;
let ks = async::KeyServer::new(ctx, uri)?;
let ks = r#async::KeyServer::new(ctx, uri)?;
Ok(KeyServer{core: core, ks: ks})
}
......@@ -86,7 +86,7 @@ impl KeyServer {
/// `cert` is used to authenticate the server.
pub fn with_cert(ctx: &Context, uri: &str, cert: Certificate) -> Result<Self> {
let core = Core::new()?;
let ks = async::KeyServer::with_cert(ctx, uri, cert)?;
let ks = r#async::KeyServer::with_cert(ctx, uri, cert)?;
Ok(KeyServer{core: core, ks: ks})
}
......
......@@ -28,11 +28,11 @@ use nettle::{
use tokio_core::reactor::Core;
use url;
use openpgp::TPK;
use openpgp::parse::Parse;
use openpgp::tpk::TPKParser;
use crate::openpgp::TPK;
use crate::openpgp::parse::Parse;
use crate::openpgp::tpk::TPKParser;
use super::{Result, Error, async};
use super::{Result, Error, r#async};
/// Stores the local_part and domain of an email address.
......@@ -210,14 +210,14 @@ pub(crate) fn parse_body<S: AsRef<str>>(body: &[u8], email_address: S)
// XXX: Maybe implement WkdServer and AWkdClient.
pub fn get<S: AsRef<str>>(email_address: S) -> Result<Vec<TPK>> {
let mut core = Core::new()?;
core.run(async::wkd::get(&email_address))
core.run(r#async::wkd::get(&email_address))
}
#[cfg(test)]
mod tests {
use openpgp::serialize::Serialize;
use openpgp::tpk::TPKBuilder;
use crate::openpgp::serialize::Serialize;
use crate::openpgp::tpk::TPKBuilder;
use super::*;
......
......@@ -22,10 +22,10 @@ extern crate sequoia_openpgp as openpgp;
extern crate sequoia_core;
extern crate sequoia_net;
use openpgp::armor::Reader;
use openpgp::TPK;
use openpgp::{Fingerprint, KeyID};
use openpgp::parse::Parse;
use crate::openpgp::armor::Reader;
use crate::openpgp::TPK;
use crate::openpgp::{Fingerprint, KeyID};
use crate::openpgp::parse::Parse;
use sequoia_core::{Context, NetworkPolicy};
use sequoia_net::KeyServer;
......
......@@ -14,11 +14,11 @@ extern crate sequoia_openpgp;
use self::sequoia_openpgp::armor;
use super::io::{Reader, ReaderKind};
use Maybe;
use MoveIntoRaw;
use MoveResultIntoRaw;
use RefRaw;
use RefMutRaw;
use crate::Maybe;
use crate::MoveIntoRaw;
use crate::MoveResultIntoRaw;
use crate::RefRaw;
use crate::RefMutRaw;
/// Represents a (key, value) pair in an armor header.
#[repr(C)]
......@@ -133,7 +133,7 @@ pub extern "C" fn pgp_armor_reader_new(inner: *mut Reader,
/// Creates a `Reader` from a file.
#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "C" fn pgp_armor_reader_from_file(errp: Option<&mut *mut ::error::Error>,
pub extern "C" fn pgp_armor_reader_from_file(errp: Option<&mut *mut crate::error::Error>,
filename: *const c_char,
mode: c_int)
-> Maybe<Reader>
......@@ -256,7 +256,7 @@ pub extern "C" fn pgp_armor_reader_kind(reader: *const Reader)
///
/// [this]: fn.pgp_armor_reader_new.html
#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "C" fn pgp_armor_reader_headers(errp: Option<&mut *mut ::error::Error>,
pub extern "C" fn pgp_armor_reader_headers(errp: Option<&mut *mut crate::error::Error>,
reader: *mut Reader,
len: *mut size_t)
-> *mut ArmorHeader {
......@@ -358,7 +358,7 @@ pub extern "C" fn pgp_armor_reader_headers(errp: Option<&mut *mut ::error::Error
/// ```
#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
pub extern "C" fn pgp_armor_writer_new
(errp: Option<&mut *mut ::error::Error>,
(errp: Option<&mut *mut crate::error::Error>,
inner: *mut super::io::Writer,
kind: c_int,
header: *const ArmorHeader,
......
......@@ -112,7 +112,7 @@ macro_rules! ffi_return_string {
($name:expr) => {{
let string = $name;
let bytes: &[u8] = string.as_ref();
::strndup(bytes).expect(
crate::strndup(bytes).expect(
&format!("Returned string {} contains a 0 byte.", stringify!($name))