breadcrumb_dto.rs
44 lignes · 1287 octets
//! Breadcrumb DTO for Feature 007 //! //! Provides data structures for breadcrumb navigation. use serde::{Deserialize, Serialize}; /// Breadcrumb item representing a single level in the navigation hierarchy #[derive(Debug, Clone, Serialize, Deserialize)] pub struct BreadcrumbItem { /// Display label for this breadcrumb level pub label: String, /// URL to navigate to (empty string for the last item, which is the current page) pub url: String, /// Helper flag for Askama compatibility (true if url is not empty) pub has_url: bool, /// Whether this item is the current page (not clickable) pub is_current: bool, } impl BreadcrumbItem { /// Create a new breadcrumb item with a URL pub fn with_url(label: impl Into<String>, url: impl Into<String>) -> Self { let url_str = url.into(); Self { label: label.into(), url: url_str.clone(), has_url: !url_str.is_empty(), is_current: false, } } /// Create a new breadcrumb item without a URL (current page) pub fn current(label: impl Into<String>) -> Self { Self { label: label.into(), url: String::new(), has_url: false, is_current: true, } } }
GitRust