[style](trx-client, trx-frontend-http): fix clippy warnings
- Derive Default for SameSite enum in auth.rs using #[default] attribute - Derive Default for CookieSameSite enum in config.rs - Replace and_then(|x| Some(y)) with map(|x| y) in extract_session_id() All clippy warnings resolved. Tests pass. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Stanislaw Grams <stanislawgrams@gmail.com>
This commit is contained in:
@@ -143,23 +143,18 @@ impl Default for AudioBridgeConfig {
|
||||
}
|
||||
|
||||
/// Cookie SameSite attribute options.
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, Default)]
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
pub enum CookieSameSite {
|
||||
/// Strict: cookie only sent in same-site context
|
||||
Strict,
|
||||
/// Lax: cookie sent with top-level navigation (default)
|
||||
#[default]
|
||||
Lax,
|
||||
/// None: cookie sent in all contexts (requires Secure=true)
|
||||
None,
|
||||
}
|
||||
|
||||
impl Default for CookieSameSite {
|
||||
fn default() -> Self {
|
||||
Self::Lax
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<str> for CookieSameSite {
|
||||
fn as_ref(&self) -> &str {
|
||||
match self {
|
||||
|
||||
@@ -132,9 +132,10 @@ impl Default for SessionStore {
|
||||
}
|
||||
|
||||
/// Cookie SameSite attribute
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||
pub enum SameSite {
|
||||
Strict,
|
||||
#[default]
|
||||
Lax,
|
||||
None,
|
||||
}
|
||||
@@ -149,12 +150,6 @@ impl SameSite {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for SameSite {
|
||||
fn default() -> Self {
|
||||
Self::Lax
|
||||
}
|
||||
}
|
||||
|
||||
/// Runtime authentication configuration
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct AuthConfig {
|
||||
@@ -260,7 +255,7 @@ pub struct LoginResponse {
|
||||
/// Extract session from cookie
|
||||
fn extract_session_id(req: &HttpRequest) -> Option<SessionId> {
|
||||
req.cookie("trx_http_sid")
|
||||
.and_then(|cookie| Some(cookie.value().to_string()))
|
||||
.map(|cookie| cookie.value().to_string())
|
||||
}
|
||||
|
||||
/// Get session from request, return role if valid
|
||||
|
||||
Reference in New Issue
Block a user