Skip to content
Closed
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
22 changes: 11 additions & 11 deletions src/calendar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ fn unescape_ical_text(input: &str) -> String {
}

/// Parse iCalendar content into a vector of (key, value) property pairs.
///
///
/// This function uses nom-based parser combinators for better performance
/// and error handling compared to manual string manipulation.
#[must_use]
Expand Down Expand Up @@ -454,9 +454,9 @@ fn split_ical_blocks(ics: &str) -> Vec<Vec<String>> {

/// Extract VTIMEZONE block from iCalendar content using nom parser.
#[must_use]
fn extract_vtimezone_block(ics: &str) -> Option<String> {
ical_parser::parse_vtimezone_block(ics).ok().flatten()
}
fn extract_vtimezone_block(ics: &str) -> Option<String> {
ical_parser::parse_vtimezone_block(ics).ok().flatten()
}

fn parse_categories_value(value: &str) -> Vec<String> {
value
Expand Down Expand Up @@ -523,9 +523,9 @@ fn format_ical_datetime_with_timezone(
/// Parse duration in ISO 8601 format using nom parser.
/// Returns the number of minutes, where negative values represent time before an event
/// (e.g., reminders). A negative sign in the input (-PT15M) returns a negative number (-15).
fn parse_duration_minutes(trigger: &str) -> Option<i32> {
ical_parser::parse_ical_duration_minutes(trigger).ok()
}
fn parse_duration_minutes(trigger: &str) -> Option<i32> {
ical_parser::parse_ical_duration_minutes(trigger).ok()
}

fn fold_ics_line(line: &str) -> String {
const MAX_LINE_LEN: usize = 75;
Expand Down Expand Up @@ -1281,10 +1281,10 @@ pub fn parse_eas_sync_mutations(xml: &str) -> Result<Vec<EasSyncMutation>> {
};
match stack.last().map(|v| v.as_slice()) {
Some(b"ClientId") => current.client_id = Some(value),
Some(b"ServerId") => {
if !stack.iter().any(|v| v.as_slice() == b"Exception") {
current.server_id = Some(value);
}
Some(b"ServerId")
if !stack.iter().any(|v| v.as_slice() == b"Exception") =>
{
current.server_id = Some(value);
}
Some(b"InstanceId") => {
current.instance_id = parse_datetime(&value);
Expand Down
10 changes: 7 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl Config {
if self.bind.is_empty() {
return Err(anyhow::anyhow!("Config: 'bind' address is required"));
}

if !self.bind.contains(':') {
return Err(anyhow::anyhow!(
"Config: 'bind' must be in format 'host:port'"
Expand All @@ -55,11 +55,15 @@ impl Config {
validate_url(&self.worker_url, "worker_url")?;

if self.worker_secret.expose_secret().len() < 16 {
return Err(anyhow::anyhow!("Config: 'worker_secret' must be at least 16 characters"));
return Err(anyhow::anyhow!(
"Config: 'worker_secret' must be at least 16 characters"
));
}

if self.hmac_secret.expose_secret().len() < 32 {
return Err(anyhow::anyhow!("Config: 'hmac_secret' must be at least 32 characters"));
return Err(anyhow::anyhow!(
"Config: 'hmac_secret' must be at least 32 characters"
));
}

if !self.gateway_host.is_empty() && self.gateway_host.contains("://") {
Expand Down
11 changes: 5 additions & 6 deletions src/eas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ struct EasRequest {
struct CommandGrammar {
namespace: &'static str,
required_tags: &'static [&'static str],
#[allow(dead_code)] // Documents allowed optional tags for protocol completeness; validation not currently required
#[allow(dead_code)]
// Documents allowed optional tags for protocol completeness; validation not currently required
optional_tags: &'static [&'static str],
}

Expand Down Expand Up @@ -299,10 +300,8 @@ fn validate_payload(command: &str, xml: &str) -> Result<(), &'static str> {
return Err("Add requires ClientId");
}
}
"meetingresponse" => {
if extract_first_tag_text(xml, b"UserResponse").is_none() {
return Err("MeetingResponse requires UserResponse");
}
"meetingresponse" if extract_first_tag_text(xml, b"UserResponse").is_none() => {
return Err("MeetingResponse requires UserResponse");
}
Comment on lines +303 to 305

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 | Confidence: High

The PR refactors a match arm for the "meetingresponse" command by moving the validation condition into a match guard. Previously, it was a separate if statement inside the arm. This change improves code clarity by consolidating the condition directly in the pattern. The logic remains identical: if the UserResponse tag is missing, an error is returned. This is a pure readability improvement with no impact on functionality or performance.

_ => {}
}
Expand Down Expand Up @@ -1465,7 +1464,7 @@ async fn handle_resolve_recipients(
let freebusy_results = join_all(freebusy_futures).await;

let mut recipient_xml = String::new();
for (recipient, freebusy) in recipients.iter().zip(freebusy_results.into_iter()) {
for (recipient, freebusy) in recipients.iter().zip(freebusy_results) {
let avail_xml = if availability_window.is_some() {
format!(
"<Availability><Status>1</Status><MergedFreeBusy>{}</MergedFreeBusy></Availability>",
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use thiserror::Error;

/// Gateway error types for protocol and application errors.
///
///
/// This enum is marked as `#[non_exhaustive]` to allow adding new error
/// variants without breaking changes to downstream code.
#[non_exhaustive]
Expand Down
4 changes: 2 additions & 2 deletions src/ews.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ fn validate_schema(action: &EwsAction, xml: &str) -> Result<(), &'static str> {
if !xml.contains(EWS_MSG_NS) && !xml.contains("xmlns:m=") {
return Err("Missing EWS messages namespace");
}

// Use const fn for compile-time optimization
if action.requires_mime_validation() && xml.contains("IncludeMimeContent") {
return Err("This operation does not support IncludeMimeContent");
}

Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion src/ews_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use crate::calendar::{
CalendarItem, extract_ews_field, extract_ews_fields, parse_ews_attendees, parse_ews_recurrence,
};
use crate::util::{xml_escape_text, xml_escape_attr};
use crate::util::{xml_escape_attr, xml_escape_text};
use quick_xml::Reader;
use quick_xml::events::{BytesEnd, BytesStart, Event};

Expand Down
Loading