Skip to content

Commit

Permalink
Fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
SHAcollision committed Aug 28, 2024
1 parent 8df4401 commit 6d89a9e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/models/homeserver/bookmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct HomeserverBookmark {
}

impl GenerateId for HomeserverBookmark {
fn get_id_data(&self) -> String {
fn _get_id_data(&self) -> String {
self.uri.clone()
}
}
Expand All @@ -28,6 +28,6 @@ fn test_create_bookmark_id() {
created_at: 1627849723,
};

let bookmark_id = bookmark.create_id();
let bookmark_id = bookmark._create_id();
println!("Generated Bookmark ID: {}", bookmark_id);
}
9 changes: 4 additions & 5 deletions src/models/homeserver/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct HomeserverTag {
}

impl GenerateId for HomeserverTag {
fn get_id_data(&self) -> String {
fn _get_id_data(&self) -> String {
format!("{}:{}", self.uri, self.label)
}
}
Expand All @@ -38,7 +38,7 @@ impl HomeserverTag {
///
/// # Returns
/// - A `String` representing the Base32-encoded tag ID derived from the `blake3` hash of the concatenated `uri` and `label`.
pub fn create_id(&self) -> String {
pub fn _create_id(&self) -> String {
// Concatenate the URI and label with a colon in between
let data = format!("{}:{}", self.uri, self.label);

Expand All @@ -52,10 +52,9 @@ impl HomeserverTag {
let half_hash = &blake3_hash.as_bytes()[..half_hash_length];

// Encode the first half of the hash in Base32 using the Z-base32 alphabet
let base32_encoded = encode(Alphabet::Z, half_hash);

// Return the Base32 encoded string as the tag ID
base32_encoded
encode(Alphabet::Z, half_hash)
}
}

Expand All @@ -67,6 +66,6 @@ fn test_create_id() {
label: "cool".to_string(),
};

let tag_id = tag.create_id();
let tag_id = tag._create_id();
println!("Generated Tag ID: {}", tag_id);
}
6 changes: 3 additions & 3 deletions src/models/homeserver/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use blake3::Hasher;

/// Trait for generating an ID based on the struct's data.
pub trait GenerateId {
fn get_id_data(&self) -> String;
fn _get_id_data(&self) -> String;

/// Creates a unique identifier for bookmarks and tag homeserver paths instance.
///
Expand All @@ -17,8 +17,8 @@ pub trait GenerateId {
///
/// # Returns
/// - A `String` representing the Base32-encoded tag ID derived from the `blake3` hash of the concatenated `uri` and `label`.
fn create_id(&self) -> String {
let data = self.get_id_data();
fn _create_id(&self) -> String {
let data = self._get_id_data();

// Create a Blake3 hash of the input data
let mut hasher = Hasher::new();
Expand Down

0 comments on commit 6d89a9e

Please sign in to comment.