Skip to content
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

chore: make clippy happy about lifetimes #642

Merged
merged 2 commits into from
Jan 14, 2025
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
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
Loading