⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

PortCollection

Struct PortCollection 

Source
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

Source

pub fn new() -> Self

Create a new, empty collection with the standard categories pre-registered.

Source

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.

Source

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.

Source

pub fn list_categories(&self) -> Vec<&str>

List all known category names (sorted).

Source

pub fn list_ports_in_category(&self, category: &str) -> Option<&[String]>

List port names within a specific category.

Source

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.

Source

pub fn total_ports(&self) -> usize

Return the total number of ports across all categories.

Source

pub fn category_count(&self) -> usize

Return the number of categories.

Source

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.

Source

pub fn last_sync_time(&self) -> u64

Return the timestamp (seconds) of the last successful sync.

Source

pub fn is_synced(&self) -> bool

Check whether the collection has been synced at least once.

Trait Implementations§

Source§

impl Default for PortCollection

Available on crate feature alloc only.
Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for PortCollection

§

impl RefUnwindSafe for PortCollection

§

impl Send for PortCollection

§

impl Sync for PortCollection

§

impl Unpin for PortCollection

§

impl UnwindSafe for PortCollection

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.