Skip to content

Commit

Permalink
Remove unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
expede committed Mar 26, 2024
1 parent 4913ad0 commit 42e59a1
Show file tree
Hide file tree
Showing 21 changed files with 31 additions and 64 deletions.
2 changes: 1 addition & 1 deletion src/ability/crud/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
};
use libipld_core::ipld::Ipld;
use serde::{Deserialize, Serialize};
use std::{collections::BTreeMap, path::PathBuf};
use std::path::PathBuf;
use thiserror::Error;

#[cfg_attr(doc, aquamarine::aquamarine)]
Expand Down
3 changes: 0 additions & 3 deletions src/ability/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ use receive::{PromisedReceive, Receive};
use send::{PromisedSend, Send};
use serde::{Deserialize, Serialize};

#[cfg(feature = "test_utils")]
use proptest::prelude::*;

#[cfg(feature = "test_utils")]
use proptest_derive::Arbitrary;

Expand Down
2 changes: 1 addition & 1 deletion src/ability/ucan/assert.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::ability::command::Command;
use crate::task::Task;
use libipld_core::{cid::Cid, ipld::Ipld};
use libipld_core::cid::Cid;

// Things that you can assert include content and receipts

Expand Down
1 change: 0 additions & 1 deletion src/ability/ucan/revoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use crate::{
};
use libipld_core::{cid::Cid, ipld::Ipld};
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
use std::fmt::Debug;

/// The fully resolved variant: ready to execute.
Expand Down
6 changes: 2 additions & 4 deletions src/delegation/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ use crate::ability::arguments::Named;
use crate::time;
use crate::{
capsule::Capsule,
crypto::{varsig, Nonce},
crypto::Nonce,
did::{Did, Verifiable},
time::{TimeBoundError, Timestamp},
};
use core::str::FromStr;
use derive_builder::Builder;
use did_url::DID;
use libipld_core::{codec::Codec, error::SerdeError, ipld::Ipld, serde as ipld_serde};
use serde::{Deserialize, Serialize};
use libipld_core::ipld::Ipld;
use std::{collections::BTreeMap, fmt::Debug};
use thiserror::Error;
use web_time::SystemTime;
Expand Down
2 changes: 1 addition & 1 deletion src/delegation/policy/predicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use super::selector::{Select, SelectorError};
use crate::ipld;
use enum_as_inner::EnumAsInner;
use libipld_core::ipld::Ipld;
use std::{fmt, str::FromStr};
use std::str::FromStr;
use thiserror::Error;

#[cfg(feature = "test_utils")]
Expand Down
11 changes: 1 addition & 10 deletions src/delegation/policy/selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,7 @@ pub use select::Select;
pub use selectable::Selectable;

use filter::Filter;
use nom::{
self,
bytes::complete::tag,
character::complete::char,
combinator::map_res,
error::context,
multi::{many0, many1},
sequence::preceded,
IResult,
};
use nom::{self, character::complete::char, multi::many0, sequence::preceded};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::cmp::Ordering;
use std::{fmt, str::FromStr};
Expand Down
6 changes: 3 additions & 3 deletions src/delegation/policy/selector/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use nom::{
self,
branch::alt,
bytes::complete::tag,
character::complete::{alphanumeric1, anychar, char, digit1},
combinator::{map_opt, map_res},
character::complete::{alphanumeric1, char, digit1},
combinator::map_res,
error::context,
multi::many1,
sequence::{delimited, preceded, terminated},
Expand Down Expand Up @@ -33,7 +33,7 @@ impl Filter {
(Filter::Values, Filter::Values) => true,
(Filter::ArrayIndex(_a), Filter::Values) => true,
(Filter::Field(_k), Filter::Values) => true,
(Filter::Try(a), Filter::Try(b)) => a.is_in(b), // FIXME Try is basically == null?
(Filter::Try(a), Filter::Try(b)) => a.is_in(b),
_ => false,
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/delegation/policy/selector/select.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use super::Selector; // FIXME cycle?
use super::Selector;
use super::{error::SelectorErrorReason, filter::Filter, Selectable, SelectorError};
use libipld_core::ipld::Ipld;
use serde::{Deserialize, Serialize};
use std::cmp::Ordering;
use std::fmt;
use std::str::FromStr;
Expand Down
4 changes: 2 additions & 2 deletions src/delegation/store/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use libipld_core::codec::Encode;
use libipld_core::ipld::Ipld;
use libipld_core::{cid::Cid, codec::Codec};
use nonempty::NonEmpty;
use std::sync::{Arc, Mutex, RwLock, RwLockReadGuard, RwLockWriteGuard};
use std::sync::{Arc, RwLock, RwLockReadGuard, RwLockWriteGuard};
use std::{
collections::{BTreeMap, BTreeSet},
convert::Infallible,
Expand Down Expand Up @@ -203,7 +203,7 @@ where
aud: &DID,
subject: &DID,
command: String,
policy: Vec<Predicate>,
_policy: Vec<Predicate>, // FIXME
now: SystemTime,
) -> Result<Option<NonEmpty<(Cid, Arc<Delegation<DID, V, Enc>>)>>, Self::DelegationStoreError>
{
Expand Down
8 changes: 0 additions & 8 deletions src/did/key/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ use crate::crypto::rs256;
#[cfg(feature = "rs512")]
use crate::crypto::rs512;

#[cfg(feature = "bls")]
use crate::crypto::bls12381;

/// Signer types that are verifiable by `did:key` [`Verifier`]s.
#[derive(Clone, EnumAsInner)]
pub enum Signer {
Expand Down Expand Up @@ -63,11 +60,6 @@ pub enum Signer {
/// `BLS 12-381` signer for the "min sig" variant.
#[cfg(feature = "bls")]
BlsMinSig(blst::min_sig::SecretKey),
// /// An unknown signer type.
// ///
// /// This is primarily for parsing, where reification is delayed
// /// until the DID method is known.
// FIXME rmeove Unknown(Vec<u8>),
}

impl signature::Signer<Signature> for Signer {
Expand Down
2 changes: 1 addition & 1 deletion src/did/preset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub enum Signer {
impl std::fmt::Debug for Signer {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Signer::Key(signer) => write!(f, "Signer::Key(HIDDEN)"),
Signer::Key(_signer) => write!(f, "Signer::Key(HIDDEN)"),
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/did/traits.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use did_url::DID;
use std::fmt;
use std::str::FromStr;

Expand Down
4 changes: 1 addition & 3 deletions src/invocation/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ use super::{
use crate::ability::arguments::Named;
use crate::ability::command::ToCommand;
use crate::ability::parse::ParseAbility;
use crate::delegation::Delegation;
use crate::invocation::payload::PayloadBuilder;
use crate::{
ability::{self, arguments, parse::ParseAbilityError, ucan::revoke::Revoke},
ability::{self, arguments},
crypto::{
signature::{self, Envelope},
varsig, Nonce,
Expand Down
31 changes: 14 additions & 17 deletions src/invocation/payload.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
use super::promise::Resolvable;
use crate::ability::command::Command;
use crate::ability::parse::ParseAbilityError;
use crate::delegation::policy::selector;
use crate::invocation::Named;
use crate::time;
use crate::{
ability::{arguments, command::ToCommand, parse::ParseAbility},
ability::{arguments::Named, command::ToCommand, parse::ParseAbility},
capsule::Capsule,
crypto::{varsig, Nonce},
crypto::Nonce,
delegation::{
self,
policy::{selector::SelectorError, Predicate},
Expand All @@ -16,7 +13,7 @@ use crate::{
time::{Expired, Timestamp},
};
use derive_builder::Builder;
use libipld_core::{cid::Cid, codec::Codec, ipld::Ipld};
use libipld_core::{cid::Cid, ipld::Ipld};
use serde::{
de::{self, MapAccess, Visitor},
ser::SerializeStruct,
Expand Down Expand Up @@ -158,7 +155,7 @@ impl<A, DID: Did> Payload<A, DID> {
where
A: ToCommand + Clone,
DID: Clone,
arguments::Named<Ipld>: From<A>,
Named<Ipld>: From<A>,
{
let now_ts = Timestamp::postel(now);

Expand All @@ -168,7 +165,7 @@ impl<A, DID: Did> Payload<A, DID> {
}
}

let args: arguments::Named<Ipld> = self.ability.clone().into();
let args: Named<Ipld> = self.ability.clone().into();

let mut cmd = self.ability.to_command();
if !cmd.ends_with('/') {
Expand Down Expand Up @@ -272,17 +269,17 @@ impl<A, DID: Did> Capsule for Payload<A, DID> {
const TAG: &'static str = "ucan/[email protected]";
}

impl<A: ToCommand, DID: Did> From<Payload<A, DID>> for arguments::Named<Ipld>
impl<A: ToCommand, DID: Did> From<Payload<A, DID>> for Named<Ipld>
where
arguments::Named<Ipld>: From<A>,
Named<Ipld>: From<A>,
{
fn from(payload: Payload<A, DID>) -> Self {
let mut args = arguments::Named::from_iter([
let mut args = Named::from_iter([
("iss".into(), { payload.issuer.to_string().into() }),
("sub".into(), { payload.subject.to_string().into() }),
("cmd".into(), { payload.ability.to_command().into() }),
("args".into(), {
Ipld::Map(arguments::Named::<Ipld>::from(payload.ability).0)
Ipld::Map(Named::<Ipld>::from(payload.ability).0)
}),
("prf".into(), {
Ipld::List(payload.proofs.iter().map(Into::into).collect())
Expand Down Expand Up @@ -316,10 +313,10 @@ where

impl<A: ToCommand, DID: Did> From<Payload<A, DID>> for Ipld
where
arguments::Named<Ipld>: From<Payload<A, DID>>,
Named<Ipld>: From<Payload<A, DID>>,
{
fn from(payload: Payload<A, DID>) -> Self {
arguments::Named::from(payload).into()
Named::from(payload).into()
}
}

Expand Down Expand Up @@ -514,14 +511,14 @@ impl<DID: Did, T> Verifiable<DID> for Payload<T, DID> {
}
}

impl<A: ParseAbility, DID: Did> TryFrom<arguments::Named<Ipld>> for Payload<A, DID>
impl<A: ParseAbility, DID: Did> TryFrom<Named<Ipld>> for Payload<A, DID>
where
<A as ParseAbility>::ArgsErr: fmt::Debug,
<DID as FromStr>::Err: fmt::Debug,
{
type Error = ParseError<A, DID>;

fn try_from(named: arguments::Named<Ipld>) -> Result<Self, Self::Error> {
fn try_from(named: Named<Ipld>) -> Result<Self, Self::Error> {
let mut subject = None;
let mut issuer = None;
let mut audience = None;
Expand Down Expand Up @@ -828,7 +825,7 @@ mod tests {
}

#[test_log::test]
fn test_non_payload(named in arguments::Named::<Ipld>::arbitrary()) {
fn test_non_payload(named in Named::<Ipld>::arbitrary()) {
// Just ensuring that a negative test shows up
let parsed = Payload::<Msg, crate::did::preset::Verifier>::try_from(named);
prop_assert!(parsed.is_err())
Expand Down
1 change: 0 additions & 1 deletion src/invocation/promise/store/memory.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use super::Store;
use crate::{did::Did, invocation::promise::Resolvable};
use libipld_core::cid::Cid;
use std::{
collections::{BTreeMap, BTreeSet},
Expand Down
1 change: 0 additions & 1 deletion src/invocation/promise/store/traits.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::{did::Did, invocation::promise::Resolvable};
use libipld_core::cid::Cid;
use std::collections::BTreeSet;

Expand Down
2 changes: 1 addition & 1 deletion src/ipld/cid.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Utilities for [`Cid`]s

use crate::ipld;
use libipld_core::{cid::Cid, ipld::Ipld, multihash::MultihashGeneric};
use libipld_core::{cid::Cid, ipld::Ipld};
use serde::{Deserialize, Serialize};
use thiserror::Error;

Expand Down
1 change: 0 additions & 1 deletion src/ipld/newtype.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use libipld_core::ipld::Ipld;
use serde::{Deserialize, Serialize};
use std::fmt;
use std::path::PathBuf;
use thiserror::Error;

Expand Down
2 changes: 1 addition & 1 deletion src/ipld/number.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Helpers for working with [`Ipld`] numerics.

use enum_as_inner::EnumAsInner;
use libipld_core::{error::SerdeError, ipld::Ipld, serde as ipld_serde};
use libipld_core::ipld::Ipld;
use serde_derive::{Deserialize, Serialize};
use thiserror::Error;

Expand Down
2 changes: 1 addition & 1 deletion src/ipld/promised.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
ability::arguments,
invocation::promise::{self, Pending, PromiseErr, PromiseOk},
ipld, url,
url,
};
use enum_as_inner::EnumAsInner;
use libipld_core::{cid::Cid, ipld::Ipld};
Expand Down

0 comments on commit 42e59a1

Please sign in to comment.