Skip to content

Commit

Permalink
chore: make clippy happy about lifetimes (#642)
Browse files Browse the repository at this point in the history
* chore: make clippy happy about lifetimes

* chore: add missing docs
  • Loading branch information
nathanielc authored Jan 14, 2025
1 parent 529f9e4 commit 2057ff0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions core/src/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ pub struct WithId<'a> {
node_key: &'a NodeKey,
expiration: u64,
}
impl<'a> BuilderState for WithId<'a> {}
impl BuilderState for WithId<'_> {}

/// Build state where the addresses are known.
pub struct WithAddresses<'a> {
node_key: &'a NodeKey,
expiration: u64,
addresses: Vec<Multiaddr>,
}
impl<'a> BuilderState for WithAddresses<'a> {}
impl BuilderState for WithAddresses<'_> {}

impl Builder<Init> {
/// Set the expiration to earliest possible value.
Expand Down Expand Up @@ -245,7 +245,7 @@ impl<'a> Builder<WithId<'a>> {
}
}
}
impl<'a> Builder<WithAddresses<'a>> {
impl Builder<WithAddresses<'_>> {
/// Finish the build producing a [`PeerKey`].
pub fn build(self) -> PeerKey {
let entry = PeerEntry::new(
Expand Down
2 changes: 1 addition & 1 deletion core/src/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub trait Signer {
fn sign_jws(&self, payload: &str) -> anyhow::Result<String>;
}

impl<'a, S: Signer + Sync> Signer for &'a S {
impl<S: Signer + Sync> Signer for &'_ S {
fn algorithm(&self) -> Algorithm {
(*self).algorithm()
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/stream_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl<'de> Deserialize<'de> for StreamId {

struct StreamIdVisitor;

impl<'de> serde::de::Visitor<'de> for StreamIdVisitor {
impl serde::de::Visitor<'_> for StreamIdVisitor {
type Value = StreamId;

fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
Expand Down
2 changes: 1 addition & 1 deletion event/src/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl<'de> Deserialize<'de> for Bytes {
}
struct BytesVisitor;

impl<'de> Visitor<'de> for BytesVisitor {
impl Visitor<'_> for BytesVisitor {
type Value = Bytes;

fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
Expand Down
4 changes: 4 additions & 0 deletions event/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ pub mod unvalidated;

pub use ceramic_core::*;

/// Shared testing logic with the crate.
#[cfg(test)]
pub mod tests {
use ceramic_core::DidDocument;

use crate::unvalidated::signed::JwkSigner;

/// Pretty print json
pub fn to_pretty_json(json_data: &[u8]) -> String {
let json: serde_json::Value = match serde_json::from_slice(json_data) {
Ok(r) => r,
Expand All @@ -27,10 +29,12 @@ pub mod tests {
serde_json::to_string_pretty(&json).unwrap()
}

/// Serialize to pretty json
pub fn serialize_to_pretty_json<T: serde::Serialize>(data: &T) -> String {
serde_json::to_string_pretty(data).unwrap()
}

/// Construct a signer with a hardcoded private key
pub async fn signer() -> JwkSigner {
JwkSigner::new(
DidDocument::new("did:key:z6Mkk3rtfoKDMMG4zyarNGwCQs44GSQ49pcYKQspHJPXSnVw"),
Expand Down

0 comments on commit 2057ff0

Please sign in to comment.