pub struct PortCollection { /* private fields */ }Expand description
A categorised collection of available ports.
Each category maps to a list of port names that belong to it. The
collection is typically populated by scanning /usr/ports/ or by
syncing with a remote ports index.
Implementations§
Source§impl PortCollection
impl PortCollection
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new, empty collection with the standard categories pre-registered.
Sourcepub fn add_port(&mut self, category: &str, port_name: &str)
pub fn add_port(&mut self, category: &str, port_name: &str)
Add a port to a category. If the category does not exist it is created automatically.
Sourcepub fn remove_port(&mut self, category: &str, port_name: &str) -> bool
pub fn remove_port(&mut self, category: &str, port_name: &str) -> bool
Remove a port from a category. Returns true if the port was found
and removed, false otherwise.
Sourcepub fn list_categories(&self) -> Vec<&str>
pub fn list_categories(&self) -> Vec<&str>
List all known category names (sorted).
Sourcepub fn list_ports_in_category(&self, category: &str) -> Option<&[String]>
pub fn list_ports_in_category(&self, category: &str) -> Option<&[String]>
List port names within a specific category.
Sourcepub fn search_ports(&self, query: &str) -> Vec<(String, String)>
pub fn search_ports(&self, query: &str) -> Vec<(String, String)>
Search all categories for ports whose name contains query
(case-insensitive). Returns (category, port_name) pairs.
Sourcepub fn total_ports(&self) -> usize
pub fn total_ports(&self) -> usize
Return the total number of ports across all categories.
Sourcepub fn category_count(&self) -> usize
pub fn category_count(&self) -> usize
Return the number of categories.
Sourcepub fn sync_collection(&mut self) -> Result<usize, KernelError>
pub fn sync_collection(&mut self) -> Result<usize, KernelError>
Synchronise the collection from the ports tree on disk.
First attempts to scan /usr/ports/ via the VFS to discover real
ports. If the VFS is not available or no ports are found, falls back
to a set of well-known demo ports so the framework is exercisable
even without a real filesystem.
Returns the number of ports discovered.
Sourcepub fn last_sync_time(&self) -> u64
pub fn last_sync_time(&self) -> u64
Return the timestamp (seconds) of the last successful sync.