run clippy fix

This commit is contained in:
Lennart K
2025-10-27 19:01:04 +01:00
parent 08041c60be
commit 0d071d3b92
94 changed files with 455 additions and 484 deletions

View File

@@ -14,7 +14,7 @@ pub struct Addressbook {
}
impl Addressbook {
pub fn format_synctoken(&self) -> String {
#[must_use] pub fn format_synctoken(&self) -> String {
format_synctoken(self.synctoken)
}
}

View File

@@ -23,7 +23,7 @@ impl<AP: AuthenticationProvider> Clone for AuthenticationLayer<AP> {
}
impl<AP: AuthenticationProvider> AuthenticationLayer<AP> {
pub fn new(auth_provider: Arc<AP>) -> Self {
pub const fn new(auth_provider: Arc<AP>) -> Self {
Self { auth_provider }
}
}

View File

@@ -35,7 +35,7 @@ impl Principal {
/// Returns true if the user is either
/// - the principal itself
/// - has full access to the prinicpal (is member)
pub fn is_principal(&self, principal: &str) -> bool {
#[must_use] pub fn is_principal(&self, principal: &str) -> bool {
if self.id == principal {
return true;
}

View File

@@ -3,8 +3,8 @@ use std::fmt::Display;
use rustical_xml::ValueSerialize;
use serde::{Deserialize, Serialize};
/// https://datatracker.ietf.org/doc/html/rfc5545#section-3.2.3
#[derive(Debug, Clone, Deserialize, Serialize, Default, PartialEq, clap::ValueEnum)]
/// <https://datatracker.ietf.org/doc/html/rfc5545#section-3.2.3>
#[derive(Debug, Clone, Deserialize, Serialize, Default, PartialEq, Eq, clap::ValueEnum)]
#[serde(rename_all = "lowercase")]
pub enum PrincipalType {
#[default]
@@ -36,13 +36,13 @@ impl TryFrom<&str> for PrincipalType {
}
impl PrincipalType {
pub fn as_str(&self) -> &'static str {
#[must_use] pub const fn as_str(&self) -> &'static str {
match self {
PrincipalType::Individual => "INDIVIDUAL",
PrincipalType::Group => "GROUP",
PrincipalType::Resource => "RESOURCE",
PrincipalType::Room => "ROOM",
PrincipalType::Unknown => "UNKNOWN",
Self::Individual => "INDIVIDUAL",
Self::Group => "GROUP",
Self::Resource => "RESOURCE",
Self::Room => "ROOM",
Self::Unknown => "UNKNOWN",
}
}
}

View File

@@ -32,19 +32,19 @@ pub struct Calendar {
}
impl Calendar {
pub fn format_synctoken(&self) -> String {
#[must_use] pub fn format_synctoken(&self) -> String {
format_synctoken(self.synctoken)
}
pub fn get_timezone(&self) -> Option<chrono_tz::Tz> {
#[must_use] pub fn get_timezone(&self) -> Option<chrono_tz::Tz> {
self.timezone_id
.as_ref()
.and_then(|tzid| chrono_tz::Tz::from_str(tzid).ok())
}
pub fn get_vtimezone(&self) -> Option<&'static str> {
#[must_use] pub fn get_vtimezone(&self) -> Option<&'static str> {
self.timezone_id
.as_ref()
.and_then(|tzid| vtimezones_rs::VTIMEZONES.get(tzid).cloned())
.and_then(|tzid| vtimezones_rs::VTIMEZONES.get(tzid).copied())
}
}

View File

@@ -8,7 +8,7 @@ use rustical_ical::{AddressObject, CalendarObject, CalendarObjectType};
use sha2::{Digest, Sha256};
use std::{collections::HashMap, sync::Arc};
pub(crate) const BIRTHDAYS_PREFIX: &str = "_birthdays_";
pub const BIRTHDAYS_PREFIX: &str = "_birthdays_";
#[derive(Constructor, Clone)]
pub struct ContactBirthdayStore<AS: AddressbookStore>(Arc<AS>);
@@ -43,7 +43,7 @@ fn birthday_calendar(addressbook: Addressbook) -> Calendar {
}
}
/// Objects are all prefixed with BIRTHDAYS_PREFIX
/// Objects are all prefixed with `BIRTHDAYS_PREFIX`
#[async_trait]
impl<AS: AddressbookStore> CalendarStore for ContactBirthdayStore<AS> {
async fn get_calendar(
@@ -165,7 +165,7 @@ impl<AS: AddressbookStore> CalendarStore for ContactBirthdayStore<AS> {
let cal_id = cal_id
.strip_prefix(BIRTHDAYS_PREFIX)
.ok_or(Error::NotFound)?;
let (addressobject_id, date_type) = object_id.rsplit_once("-").ok_or(Error::NotFound)?;
let (addressobject_id, date_type) = object_id.rsplit_once('-').ok_or(Error::NotFound)?;
self.0
.get_object(principal, cal_id, addressobject_id, show_deleted)
.await?

View File

@@ -30,7 +30,7 @@ pub enum Error {
}
impl Error {
pub fn status_code(&self) -> StatusCode {
#[must_use] pub const fn status_code(&self) -> StatusCode {
match self {
Self::NotFound => StatusCode::NOT_FOUND,
Self::AlreadyExists => StatusCode::CONFLICT,

View File

@@ -1,10 +1,10 @@
const SYNC_NAMESPACE: &str = "github.com/lennart-k/rustical/ns/";
pub fn format_synctoken(synctoken: i64) -> String {
#[must_use] pub fn format_synctoken(synctoken: i64) -> String {
format!("{SYNC_NAMESPACE}{synctoken}")
}
pub fn parse_synctoken(synctoken: &str) -> Option<i64> {
#[must_use] pub fn parse_synctoken(synctoken: &str) -> Option<i64> {
if !synctoken.starts_with(SYNC_NAMESPACE) {
return None;
}