### Setup Constructor Source: https://docs.rs/netavark/1.17.2/netavark/commands/setup/struct.Setup.html Initializes a new Setup instance with the path to the network namespace. This is used to configure the network namespace. ```rust pub fn new(network_namespace_path: String) -> Self> ``` -------------------------------- ### Setup::exec Source: https://docs.rs/netavark/1.17.2/netavark/commands/setup/struct.Setup.html Executes the setup command with the specified configuration. This method applies the network configuration to the target network namespace. ```APIDOC ## Setup::exec ### Description Executes the setup command with the specified configuration. This method applies the network configuration to the target network namespace. ### Signature `pub fn exec(&self, input_file: Option, config_dir: Option, firewall_driver: Option, aardvark_bin: OsString, plugin_directories: Option>, rootless: bool) -> NetavarkResult<()>` ### Parameters * `input_file` (Option) - Optional path to an input file. * `config_dir` (Option) - Optional path to the configuration directory. * `firewall_driver` (Option) - Optional firewall driver to use. * `aardvark_bin` (OsString) - Path to the aardvark binary. * `plugin_directories` (Option>) - Optional list of plugin directories. * `rootless` (bool) - Flag indicating if the operation should be run in rootless mode. ``` -------------------------------- ### setup Function Signature Source: https://docs.rs/netavark/1.17.2/netavark/dhcp_proxy/ip/fn.setup.html This snippet shows the signature of the `setup` function, detailing its parameters and return type. ```APIDOC ## setup ```rust pub fn setup( lease: &NetavarkLease, interface: &str, ns_path: &str, ) -> Result<(), ProxyError> ``` ### Parameters * `lease`: A reference to a `NetavarkLease` object. * `interface`: A string slice representing the network interface name. * `ns_path`: A string slice representing the path to the network namespace. ### Returns Returns `Ok(())` on success, or a `ProxyError` on failure. ``` -------------------------------- ### Setup Network Configuration Source: https://docs.rs/netavark/1.17.2/netavark/dhcp_proxy/lib/g_rpc/netavark_proxy_client/struct.NetavarkProxyClient.html Initiates the network setup process. This is a client-side streaming operation designed to detect client disconnections. ```rust pub async fn setup( &mut self, request: impl IntoRequest, ) -> Result, Status> ``` -------------------------------- ### Setup::new Source: https://docs.rs/netavark/1.17.2/netavark/commands/setup/struct.Setup.html Creates a new Setup instance. This command configures the given network namespace with the provided configuration, establishing necessary interfaces and firewall rules. ```APIDOC ## Setup::new ### Description Creates a new Setup instance. This command configures the given network namespace with the provided configuration, establishing necessary interfaces and firewall rules. ### Signature `pub fn new(network_namespace_path: String) -> Self` ### Parameters * `network_namespace_path` (String) - The path to the network namespace to configure. ``` -------------------------------- ### Setup Struct Definition Source: https://docs.rs/netavark/1.17.2/netavark/commands/setup/struct.Setup.html Defines the Setup struct, which is used for network namespace configuration. It has private fields. ```rust pub struct Setup { /* private fields */ } ``` -------------------------------- ### NetavarkProxy Setup Method Source: https://docs.rs/netavark/1.17.2/netavark/dhcp_proxy/lib/g_rpc/netavark_proxy_server/trait.NetavarkProxy.html The setup method handles network configuration and lease acquisition. It is a client-side streaming method designed to detect client disconnections. ```rust fn setup<'life0, 'async_trait>( &'life0 self, request: Request, ) -> Pin, Status>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; ``` -------------------------------- ### Setup Execution Source: https://docs.rs/netavark/1.17.2/netavark/commands/setup/struct.Setup.html Executes the setup command, configuring the network namespace with provided options. This method handles interface and firewall rule creation. ```rust pub fn exec( &self, input_file: Option, config_dir: Option, firewall_driver: Option, aardvark_bin: OsString, plugin_directories: Option>, rootless: bool, ) -> NetavarkResult<()> ``` -------------------------------- ### Args Trait Implementation for Setup Source: https://docs.rs/netavark/1.17.2/netavark/commands/setup/struct.Setup.html Implements the Args trait for the Setup struct, providing methods to manage command-line arguments. ```rust fn group_id() -> Option ``` ```rust fn augment_args<'b>(__clap_app: Command) -> Command> ``` ```rust fn augment_args_for_update<'b>(__clap_app: Command) -> Command> ``` -------------------------------- ### Setup Network Configuration Source: https://docs.rs/netavark/1.17.2/netavark/plugin/trait.Plugin.html Implement this method to define how the network configuration is set up for a given network namespace and options. ```rust fn setup( &self, netns: String, opts: NetworkPluginExec, ) -> Result> ``` -------------------------------- ### Function Signature: setup Source: https://docs.rs/netavark/1.17.2/netavark/dhcp_proxy/ip/fn.setup.html This function signature defines the setup function for DHCP proxy IP configuration. It takes a lease, interface name, and namespace path as input and returns a Result indicating success or a ProxyError. ```rust pub fn setup( lease: &NetavarkLease, interface: &str, ns_path: &str, ) -> Result<(), ProxyError> ``` -------------------------------- ### Into Trait Implementation for Setup Source: https://docs.rs/netavark/1.17.2/netavark/commands/setup/struct.Setup.html Implements the Into trait for the Setup struct, allowing conversion into other types that implement From. ```rust fn into(self) -> U> ``` -------------------------------- ### Aardvark::start_aardvark_server Source: https://docs.rs/netavark/1.17.2/netavark/dns/aardvark/struct.Aardvark.html Starts the aardvark-dns server. ```APIDOC ## pub fn start_aardvark_server(&self) -> NetavarkResult<()> ### Description Starts the aardvark-dns server process. ### Returns `NetavarkResult<()>` indicating success or failure. ``` -------------------------------- ### Nftables setup_network Method Source: https://docs.rs/netavark/1.17.2/netavark/firewall/nft/struct.Nftables.html Sets up firewall rules for a given network configuration. Requires network setup details and an optional D-Bus connection. ```rust fn setup_network( &self, network_setup: SetupNetwork, dbus_conn: &Option, ) -> NetavarkResult<()> ``` -------------------------------- ### File Metadata Operations with `and_then` Source: https://docs.rs/netavark/1.17.2/netavark/error/type.NetavarkResult.html Shows how to use `and_then` to chain fallible operations like getting file metadata and its modification time. This example illustrates handling potential errors like 'NotFound'. ```rust use std::{io::ErrorKind, path::Path}; // Note: on Windows "/" maps to "C:\\" let root_modified_time = Path::new("/").metadata().and_then(|md| md.modified()); assert!(root_modified_time.is_ok()); let should_fail = Path::new("/bad/path").metadata().and_then(|md| md.modified()); assert!(should_fail.is_err()); assert_eq!(should_fail.unwrap_err().kind(), ErrorKind::NotFound); ``` -------------------------------- ### Start Aardvark Server Source: https://docs.rs/netavark/1.17.2/netavark/dns/aardvark/struct.Aardvark.html Starts the aardvark-dns server. Returns a NetavarkResult indicating success or failure. ```rust pub fn start_aardvark_server(&self) -> NetavarkResult<()> ``` -------------------------------- ### Instrument Trait Implementation for Setup Source: https://docs.rs/netavark/1.17.2/netavark/commands/setup/struct.Setup.html Implements the Instrument trait for the Setup struct, used for tracing and instrumentation. ```rust fn instrument(self, span: Span) -> Instrumented ``` ```rust fn in_current_span(self) -> Instrumented ``` -------------------------------- ### Create a new NetavarkErrorList Source: https://docs.rs/netavark/1.17.2/netavark/error/struct.NetavarkErrorList.html Initializes an empty NetavarkErrorList. Use this to start collecting errors. ```rust pub fn new() -> Self ``` -------------------------------- ### Parser Trait Implementation for Setup Source: https://docs.rs/netavark/1.17.2/netavark/commands/setup/struct.Setup.html Implements the Parser trait for the Setup struct, providing methods for parsing command-line arguments. ```rust fn parse() -> Self> ``` ```rust fn try_parse() -> Result ``` ```rust fn parse_from(itr: I) -> Self where I: IntoIterator, T: Into + Clone, ``` ```rust fn try_parse_from(itr: I) -> Result where I: IntoIterator, T: Into + Clone, ``` ```rust fn update_from(&mut self, itr: I) where I: IntoIterator, T: Into + Clone, ``` ```rust fn try_update_from(&mut self, itr: I) -> Result<(), Error> where I: IntoIterator, T: Into + Clone, ``` -------------------------------- ### Setup Network Firewall Rules Source: https://docs.rs/netavark/1.17.2/netavark/firewall/firewalld/struct.FirewallD.html Sets up firewall rules for a given network configuration. It takes a SetupNetwork object and an optional D-Bus connection. ```rust fn setup_network( &self, network_setup: SetupNetwork, _dbus_con: &Option, ) -> NetavarkResult<()> ``` -------------------------------- ### Setup Port Forwarding Source: https://docs.rs/netavark/1.17.2/netavark/firewall/firewalld/struct.FirewallD.html Sets up port-forwarding firewall rules for a container. It requires a PortForwardConfig and an optional D-Bus connection. ```rust fn setup_port_forward( &self, setup_portfw: PortForwardConfig<'_>, _dbus_con: &Option, ) -> Result<(), NetavarkError> ``` -------------------------------- ### Setup Port Forwarding Rules Source: https://docs.rs/netavark/1.17.2/netavark/firewall/trait.FirewallDriver.html Implementations of this method should set up firewall rules for port forwarding for a specific container. Requires a PortForwardConfig and an optional D-Bus connection. ```rust fn setup_port_forward( &self, setup_pw: PortForwardConfig<'_>, dbus_con: &Option, ) -> NetavarkResult<()> ``` -------------------------------- ### FromArgMatches Trait Implementation for Setup Source: https://docs.rs/netavark/1.17.2/netavark/commands/setup/struct.Setup.html Implements the FromArgMatches trait for the Setup struct, enabling instantiation from command-line argument matches. ```rust fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result ``` ```rust fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result ``` ```rust fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error> ``` ```rust fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error> ``` -------------------------------- ### CommandFactory Trait Implementation for Setup Source: https://docs.rs/netavark/1.17.2/netavark/commands/setup/struct.Setup.html Implements the CommandFactory trait for the Setup struct, enabling the creation of clap Commands for argument parsing. ```rust fn command<'b>() -> Command> ``` ```rust fn command_for_update<'b>() -> Command> ``` -------------------------------- ### SetupNetwork Struct Definition Source: https://docs.rs/netavark/1.17.2/netavark/network/internal_types/struct.SetupNetwork.html Defines the structure for network setup options, including subnets, bridge name, network ID, and isolation settings. ```rust pub struct SetupNetwork { pub subnets: Option>, pub bridge_name: String, pub network_id: String, pub network_hash_name: String, pub isolation: IsolateOption, pub dns_port: u16, } ``` -------------------------------- ### IntoRequest Trait Implementation for Setup Source: https://docs.rs/netavark/1.17.2/netavark/commands/setup/struct.Setup.html Implements the IntoRequest trait for the Setup struct, used for wrapping messages in a tonic::Request. ```rust fn into_request(self) -> Request ``` -------------------------------- ### NetworkDriver - setup Source: https://docs.rs/netavark/1.17.2/netavark/network/bridge/struct.Bridge.html Sets up network interfaces and firewall rules for the driver. It requires mutable access to netlink sockets and returns a status block and an optional Aardvark entry. ```rust fn setup( &self, netlink_sockets: (&mut Socket, &mut Socket), ) -> NetavarkResult<(StatusBlock, Option>)> > ``` -------------------------------- ### Setup Network - IptablesDriver Source: https://docs.rs/netavark/1.17.2/netavark/firewall/iptables/struct.IptablesDriver.html Sets up firewall rules for a given network configuration. This method is part of the FirewallDriver trait implementation. ```rust fn setup_network( &self, network_setup: SetupNetwork, dbus_con: &Option, ) -> NetavarkResult<()> ``` -------------------------------- ### Product of Results Example Source: https://docs.rs/netavark/1.17.2/netavark/error/type.NetavarkResult.html Demonstrates how to compute the product of a collection of Results. If any element fails to parse, the entire operation returns an Err. Otherwise, it returns the Ok product. ```rust let nums = vec!["5", "10", "1", "2"]; let total: Result = nums.iter().map(|w| w.parse::()).product(); assert_eq!(total, Ok(100)); ``` ```rust let nums = vec!["5", "10", "one", "2"]; let total: Result = nums.iter().map(|w| w.parse::()).product(); assert!(total.is_err()); ``` -------------------------------- ### write_fw_config Source: https://docs.rs/netavark/1.17.2/netavark/firewall/state/index.html Stores firewall configurations on disk after setup, allowing the firewalld reload service to access them. ```APIDOC ## write_fw_config ### Description Stores the firewall configurations on disk. This should be called after firewall setup to allow the firewalld reload service to read the configs later and re-add the rules. ### Method (Not specified, likely a function call within the Rust library) ### Endpoint (Not applicable, this is a library function) ### Parameters (No parameters explicitly documented) ### Response (No response details explicitly documented) ``` -------------------------------- ### NetworkConfig Get Lease Source: https://docs.rs/netavark/1.17.2/netavark/dhcp_proxy/lib/g_rpc/struct.NetworkConfig.html Asynchronously obtains a DHCP lease via gRPC from the nvproxy-server. Requires the path to the Unix domain socket (uds). ```rust pub async fn get_lease(self, p: &str) -> Result ``` -------------------------------- ### Setup Port Forward - IptablesDriver Source: https://docs.rs/netavark/1.17.2/netavark/firewall/iptables/struct.IptablesDriver.html Sets up port-forwarding firewall rules for a container. This method is part of the FirewallDriver trait implementation. ```rust fn setup_port_forward( &self, setup_portfw: PortForwardConfig<'_>, dbus_con: &Option, ) -> NetavarkResult<()> ``` -------------------------------- ### NetworkConfig Methods Source: https://docs.rs/netavark/1.17.2/netavark/dhcp_proxy/lib/g_rpc/struct.NetworkConfig.html Provides methods for interacting with the NetworkConfig struct, including setting and getting the version, loading configuration, and managing DHCP leases. ```APIDOC ## NetworkConfig Implementations ### impl NetworkConfig #### pub fn version(&self) -> Version Returns the enum value of `version`, or the default if the field is set to an invalid enum value. #### pub fn set_version(&mut self, value: Version) Sets `version` to the provided enum value. #### pub fn load(path: &str) -> Result> #### pub async fn get_lease(self, p: &str) -> Result get_lease is a wrapper function for obtaining a lease over grpc from the nvproxy-server ##### Arguments * `p`: path to uds returns: Result #### pub async fn drop_lease(self, p: &str) -> Result drop_lease is a wrapper function to release the current DHCP lease via the nvproxy ##### Arguments * `p`: path to uds returns: Result ``` -------------------------------- ### Sum of Results Example Source: https://docs.rs/netavark/1.17.2/netavark/error/type.NetavarkResult.html Illustrates summing a collection of Results. The operation short-circuits and returns the first Err encountered. If all elements are Ok, it returns the Ok sum. ```rust let f = |&x: &i32| if x < 0 { Err("Negative element found") } else { Ok(x) }; let v = vec![1, 2]; let res: Result = v.iter().map(f).sum(); assert_eq!(res, Ok(3)); ``` ```rust let v = vec![1, -2]; let res: Result = v.iter().map(f).sum(); assert_eq!(res, Err("Negative element found")); ``` -------------------------------- ### write_fw_config Source: https://docs.rs/netavark/1.17.2/netavark/firewall/state/fn.write_fw_config.html Stores the firewall configurations on disk. This function should be called after firewall setup to allow the firewalld reload service to read the configurations later and re-add the rules. ```APIDOC ## Function write_fw_config ### Description Store the firewall configs on disk. This should be caller after firewall setup to allow the firewalld reload service to read the configs later and readd the rules. ### Signature ```rust pub fn write_fw_config( config_dir: &Path, network_id: &str, container_id: &str, fw_driver: &str, net_conf: &SetupNetwork, port_conf: &PortForwardConfig<'_>, ) -> NetavarkResult<()> ``` ``` -------------------------------- ### Deprecated: Get cause of NetavarkError Source: https://docs.rs/netavark/1.17.2/netavark/error/enum.NetavarkError.html Deprecated method for getting the cause of the error. Replaced by Error::source. ```rust fn cause(&self) -> Option<&dyn Error> ``` -------------------------------- ### setup_network Source: https://docs.rs/netavark/1.17.2/netavark/firewall/trait.FirewallDriver.html Set up firewall rules for the given network. ```APIDOC ## setup_network ### Description Set up firewall rules for the given network. ### Method `setup_network` ### Parameters - `network_setup`: `SetupNetwork` - `dbus_con`: `&Option` ### Returns `NetavarkResult<()>` ``` -------------------------------- ### NetworkDriver::setup Method Source: https://docs.rs/netavark/1.17.2/netavark/network/driver/trait.NetworkDriver.html Sets up network interfaces and firewall rules for the driver. It requires mutable access to netlink sockets and returns status information. ```rust fn setup( &self, netlink_sockets: (&mut Socket, &mut Socket), ) -> NetavarkResult<(StatusBlock, Option>)> ``` -------------------------------- ### PluginDriver::setup Method Source: https://docs.rs/netavark/1.17.2/netavark/network/plugin/struct.PluginDriver.html Sets up network interfaces and firewall rules for the driver. It requires mutable access to netlink sockets and returns a StatusBlock and an optional AardvarkEntry. ```rust fn setup( &self, _netlink_sockets: (&mut Socket, &mut Socket), ) -> NetavarkResult<(StatusBlock, Option>)> ``` -------------------------------- ### NetavarkProxy::setup Source: https://docs.rs/netavark/1.17.2/netavark/dhcp_proxy/lib/g_rpc/netavark_proxy_server/trait.NetavarkProxy.html Sets up network configuration and returns lease information. This method is designed for client-side streaming to detect client disconnections. ```APIDOC ## fn setup<'life0, 'async_trait>( &'life0 self, request: Request, ) -> Pin, Status>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait ``` -------------------------------- ### Nftables setup_port_forward Method Source: https://docs.rs/netavark/1.17.2/netavark/firewall/nft/struct.Nftables.html Sets up port-forwarding firewall rules for a container. Requires port forwarding configuration and an optional D-Bus connection. ```rust fn setup_port_forward( &self, setup_portfw: PortForwardConfig<'_>, dbus_conn: &Option, ) -> NetavarkResult<()> ``` -------------------------------- ### Deprecated: Get description of NetavarkError Source: https://docs.rs/netavark/1.17.2/netavark/error/enum.NetavarkError.html Deprecated method for getting a string description of the error. Use the Display impl or to_string() instead. ```rust fn description(&self) -> &str ``` -------------------------------- ### Create Network Configuration Source: https://docs.rs/netavark/1.17.2/netavark/plugin/trait.Plugin.html Implement this method to define how a new network is created. ```rust fn create(&self, network: Network) -> Result> ``` -------------------------------- ### FirewallDriver Implementation for Fwnone - setup_network Source: https://docs.rs/netavark/1.17.2/netavark/firewall/fwnone/struct.Fwnone.html Implements the setup_network function for the Fwnone driver. This function does nothing as Fwnone does not set up any network firewall rules. ```rust fn setup_network( &self, _network_setup: SetupNetwork, _dbus_conn: &Option, ) -> NetavarkResult<()> ``` -------------------------------- ### Any - type_id Source: https://docs.rs/netavark/1.17.2/netavark/network/bridge/struct.Bridge.html Gets the `TypeId` of the instance. This is part of the Any trait implementation. ```rust fn type_id(&self) -> TypeId > ``` -------------------------------- ### setup_port_forward Source: https://docs.rs/netavark/1.17.2/netavark/firewall/trait.FirewallDriver.html Set up port-forwarding firewall rules for a given container. ```APIDOC ## setup_port_forward ### Description Set up port-forwarding firewall rules for a given container. ### Method `setup_port_forward` ### Parameters - `setup_pw`: `PortForwardConfig<'_>` - `dbus_con`: `&Option` ### Returns `NetavarkResult<()>` ``` -------------------------------- ### Aardvark::notify Source: https://docs.rs/netavark/1.17.2/netavark/dns/aardvark/struct.Aardvark.html Notifies the aardvark-dns server about changes, such as starting or updating. ```APIDOC ## pub fn notify(&self, start: bool, is_update: bool) -> NetavarkResult<()> ### Description Sends a notification to the aardvark-dns server to indicate a state change, like starting or updating. ### Parameters * `start` (bool) - Indicates if the notification is for starting the service. * `is_update` (bool) - Indicates if the notification is for an update. ### Returns `NetavarkResult<()>` indicating success or failure. ``` -------------------------------- ### get_supported_firewall_driver Source: https://docs.rs/netavark/1.17.2/netavark/firewall/fn.get_supported_firewall_driver.html Get the preferred firewall implementation for the current system configuration. ```APIDOC ## Function get_supported_firewall_driver ### Description Get the preferred firewall implementation for the current system configuration. ### Signature ```rust pub fn get_supported_firewall_driver( driver_name: Option, ) -> NetavarkResult> ``` ### Parameters #### Path Parameters - **driver_name** (Option) - Optional - The name of the firewall driver to retrieve. If not provided, the system's preferred driver will be returned. ``` -------------------------------- ### PluginExec::new Source: https://docs.rs/netavark/1.17.2/netavark/plugin/struct.PluginExec.html Constructs a new PluginExec instance with the provided plugin and information. ```APIDOC ## PluginExec::new ### Description Constructs a new `PluginExec` instance with the provided plugin and information. ### Signature ```rust pub fn new(plugin: P, info: Info) -> Self ``` ### Parameters * `plugin`: The plugin implementation. * `info`: Information related to the plugin execution. ``` -------------------------------- ### Notify Aardvark Server Source: https://docs.rs/netavark/1.17.2/netavark/dns/aardvark/struct.Aardvark.html Notifies the aardvark server about changes, such as starting or updating. ```rust pub fn notify(&self, start: bool, is_update: bool) -> NetavarkResult<()> ``` -------------------------------- ### new Source: https://docs.rs/netavark/1.17.2/netavark/firewall/firewalld/fn.new.html Creates a new instance of the firewalld firewall driver, requiring a connection object. ```APIDOC ## new ### Description Creates a new instance of the firewalld firewall driver. ### Signature ```rust pub fn new(conn: Connection) -> Result, NetavarkError> ``` ### Parameters #### Path Parameters - **conn** (Connection) - Required - The connection object required for the firewall driver. ``` -------------------------------- ### FirewallDriver Implementation for Fwnone - setup_port_forward Source: https://docs.rs/netavark/1.17.2/netavark/firewall/fwnone/struct.Fwnone.html Implements the setup_port_forward function for the Fwnone driver. This function does nothing as Fwnone does not set up any port forwarding rules. ```rust fn setup_port_forward( &self, _setup_portfw: PortForwardConfig<'_>, _dbus_conn: &Option, ) -> NetavarkResult<()> ``` -------------------------------- ### Any::type_id Implementation Source: https://docs.rs/netavark/1.17.2/netavark/commands/update/struct.Update.html Gets the TypeId of the Update struct, used for dynamic type checking. ```rust fn type_id(&self) -> TypeId> ``` -------------------------------- ### SetupNetwork Struct Definition Source: https://docs.rs/netavark/1.17.2/netavark/network/internal_types/struct.SetupNetwork.html This snippet shows the definition of the SetupNetwork struct, outlining its fields and their types. ```APIDOC ## Struct SetupNetwork ### Summary ```rust pub struct SetupNetwork { pub subnets: Option>, pub bridge_name: String, pub network_id: String, pub network_hash_name: String, pub isolation: IsolateOption, pub dns_port: u16, } ``` ### Description SetupNetwork contains options for setting up a container. ### Fields * `subnets: Option>` - subnets used for this network * `bridge_name: String` - bridge interface name * `network_id: String` - id for the network * `network_hash_name: String` - hash id for the network * `isolation: IsolateOption` - isolation determines whether the network can communicate with others outside of its interface * `dns_port: u16` - port used for the dns server ``` -------------------------------- ### Implement Any for T Source: https://docs.rs/netavark/1.17.2/netavark/commands/version/struct.Version.html Provides a method to get the TypeId of a type, useful for runtime type identification. ```rust fn type_id(&self) -> TypeId Gets the `TypeId` of `self`. Read more ``` -------------------------------- ### Info::new Source: https://docs.rs/netavark/1.17.2/netavark/plugin/struct.Info.html Constructs a new Info instance for a plugin. ```APIDOC ## pub fn new(version: String, api_version: String, extra_info: Option>) -> Self Constructs a new Info instance with the provided version, API version, and optional extra information. ``` -------------------------------- ### LeaseCache::len - Get Size Source: https://docs.rs/netavark/1.17.2/netavark/dhcp_proxy/cache/struct.LeaseCache.html Returns the number of leases currently stored in the cache. ```rust pub fn len(&self) -> usize ``` -------------------------------- ### Get Network Link Information Source: https://docs.rs/netavark/1.17.2/netavark/network/netlink/struct.Socket.html Retrieves detailed information about a specific network link identified by its ID. ```rust pub fn get_link(&mut self, id: LinkID) -> NetavarkResult ``` -------------------------------- ### Create New Plugin Info Source: https://docs.rs/netavark/1.17.2/netavark/plugin/struct.Info.html Constructs a new Info instance with the provided version, API version, and optional extra information. ```rust pub fn new( version: String, api_version: String, extra_info: Option>, ) -> Self ``` -------------------------------- ### Vlan::new Source: https://docs.rs/netavark/1.17.2/netavark/network/vlan/struct.Vlan.html Constructs a new Vlan instance. ```APIDOC ## Vlan::new ### Description Creates a new `Vlan` instance with the provided driver information. ### Signature ```rust pub fn new(info: DriverInfo<'a>) -> Self ``` ### Parameters * `info` (`DriverInfo<'a>`) - Information required to initialize the Vlan driver. ``` -------------------------------- ### LeaseRange Struct Definition Source: https://docs.rs/netavark/1.17.2/netavark/network/types/struct.LeaseRange.html Defines the structure for a lease range, including optional start and end IP addresses. ```APIDOC ## Struct LeaseRange ### Summary `pub struct LeaseRange { pub end_ip: Option, pub start_ip: Option, }` ### Description LeaseRange contains the range where IP are leased. ### Fields * `end_ip: Option` - EndIP last IP in the subnet which should be used to assign ips. * `start_ip: Option` - StartIP first IP in the subnet which should be used to assign ips. ``` -------------------------------- ### NetavarkErrorList::new Source: https://docs.rs/netavark/1.17.2/netavark/error/struct.NetavarkErrorList.html Creates a new, empty NetavarkErrorList. ```APIDOC ## NetavarkErrorList::new ### Description Creates a new, empty `NetavarkErrorList`. ### Method `pub fn new() -> Self` ``` -------------------------------- ### LeaseRange Struct Definition Source: https://docs.rs/netavark/1.17.2/netavark/network/types/struct.LeaseRange.html Defines the structure for a lease range, including optional start and end IP addresses. ```rust pub struct LeaseRange { pub end_ip: Option, pub start_ip: Option, } ``` -------------------------------- ### Create DhcpV4Service Instance Source: https://docs.rs/netavark/1.17.2/netavark/dhcp_proxy/dhcp_service/struct.DhcpV4Service.html Initializes a new DhcpV4Service with network configuration and a timeout. This function is asynchronous. ```rust pub async fn new( nc: NetworkConfig, timeout: u32, ) -> Result ``` -------------------------------- ### CreateLinkOptions::new Source: https://docs.rs/netavark/1.17.2/netavark/network/netlink_route/struct.CreateLinkOptions.html Constructor for CreateLinkOptions. Initializes a new instance with a given name and link kind. ```APIDOC ### impl CreateLinkOptions<'_> #### pub fn new(name: String, kind: InfoKind) -> Self Creates a new `CreateLinkOptions` instance with the specified name and link kind. ``` -------------------------------- ### Aardvark::new Source: https://docs.rs/netavark/1.17.2/netavark/dns/aardvark/struct.Aardvark.html Constructs a new Aardvark instance with the provided configuration. ```APIDOC ## pub fn new( config: PathBuf, rootless: bool, aardvark_bin: OsString, port: u16, ) -> Self ### Description Creates a new instance of the Aardvark struct. ### Parameters * `config` (PathBuf) - The configuration directory path for aardvark. * `rootless` (bool) - A flag indicating if the container is rootless. * `aardvark_bin` (OsString) - The path to the aardvark-dns binary. * `port` (u16) - The port number to bind to. ``` -------------------------------- ### Providing a Default Value with `unwrap_or` Source: https://docs.rs/netavark/1.17.2/netavark/error/type.NetavarkResult.html Use `unwrap_or` to get the `Ok` value or a provided default value if the Result is `Err`. ```APIDOC ## pub fn unwrap_or(self, default: T) -> T ### Description Returns the contained `Ok` value or a provided default. Arguments passed to `unwrap_or` are eagerly evaluated; if you are passing the result of a function call, it is recommended to use `unwrap_or_else`, which is lazily evaluated. ### Method `unwrap_or` ### Parameters - `default` (T): The default value to return if `self` is `Err`. ### Examples ```rust let default = 2; let x: Result = Ok(9); assert_eq!(x.unwrap_or(default), 9); let x: Result = Err("error"); assert_eq!(x.unwrap_or(default), default); ``` ``` -------------------------------- ### Get Firewall Driver Name Source: https://docs.rs/netavark/1.17.2/netavark/firewall/firewalld/struct.FirewallD.html Returns the name of the firewall driver being used. This is useful for identifying the active firewall backend. ```rust fn driver_name(&self) -> &str ``` -------------------------------- ### Get source of NetavarkError Source: https://docs.rs/netavark/1.17.2/netavark/error/enum.NetavarkError.html Implementation of the Error trait's source method, returning the lower-level error if one exists. ```rust fn source(&self) -> Option<&(dyn Error + 'static)> ``` -------------------------------- ### Socket Initialization Source: https://docs.rs/netavark/1.17.2/netavark/network/netlink/struct.Socket.html Creates a new Socket instance. This is the entry point for all Netlink operations. ```APIDOC ## new() ### Description Creates a new Socket instance. ### Returns - `NetavarkResult>`: A Result containing the new Socket or an error. ``` -------------------------------- ### Get NetavarkError exit code Source: https://docs.rs/netavark/1.17.2/netavark/error/enum.NetavarkError.html Retrieves the integer exit code associated with the NetavarkError, useful for system exit status. ```rust pub fn get_exit_code(&self) -> i32 ``` -------------------------------- ### serve Function Source: https://docs.rs/netavark/1.17.2/netavark/commands/dhcp_proxy/fn.serve.html The `serve` function is the entry point for the DHCP proxy functionality. It accepts configuration options and returns a result indicating success or failure. ```APIDOC ## serve ### Description Initiates the DHCP proxy service. ### Signature ```rust pub fn serve(opts: Opts) -> NetavarkResult<()> ``` ### Parameters * **opts** (`Opts`) - Configuration options for the DHCP proxy. ``` -------------------------------- ### is_firewalld_strict_forward_enabled Source: https://docs.rs/netavark/1.17.2/netavark/firewall/firewalld/fn.is_firewalld_strict_forward_enabled.html Checks if firewalld's StrictForwardPorts setting is enabled. Returns false if firewalld is not installed, not running, or if there is any error with the process. ```APIDOC ## Function is_firewalld_strict_forward_enabled ### Description Check whether firewalld’s StrictForwardPorts setting is enabled. Returns false if firewalld is not installed, not running, or there is any error with the process. ### Signature ```rust pub fn is_firewalld_strict_forward_enabled( dbus_con: &Option, ) -> bool ``` ### Parameters * `dbus_con` (*Option*<*Connection*>): An optional D-Bus connection object. ``` -------------------------------- ### NetavarkProxyServer Constructors Source: https://docs.rs/netavark/1.17.2/netavark/dhcp_proxy/lib/g_rpc/netavark_proxy_server/struct.NetavarkProxyServer.html Provides methods to create new instances of NetavarkProxyServer. `new` takes an inner service, `from_arc` takes an Arc-wrapped inner service, and `with_interceptor` allows adding a custom interceptor. ```rust pub fn new(inner: T) -> Self ``` ```rust pub fn from_arc(inner: Arc) -> Self ``` ```rust pub fn with_interceptor( inner: T, interceptor: F, ) -> InterceptedService where F: Interceptor, ``` -------------------------------- ### NetavarkProxy Trait Definition Source: https://docs.rs/netavark/1.17.2/netavark/dhcp_proxy/lib/g_rpc/netavark_proxy_server/trait.NetavarkProxy.html Defines the core gRPC methods that must be implemented for NetavarkProxyServer. Includes setup, teardown, and clean functionalities. ```rust pub trait NetavarkProxy: Send + Sync + 'static { // Required methods fn setup<'life0, 'async_trait>( &'life0 self, request: Request, ) -> Pin, Status>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn teardown<'life0, 'async_trait>( &'life0 self, request: Request, ) -> Pin, Status>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn clean<'life0, 'async_trait>( &'life0 self, request: Request, ) -> Pin, Status>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; } ``` -------------------------------- ### Create NetavarkProxyClient with Origin Source: https://docs.rs/netavark/1.17.2/netavark/dhcp_proxy/lib/g_rpc/netavark_proxy_client/struct.NetavarkProxyClient.html Constructs a new NetavarkProxyClient with a specified origin URI. ```rust pub fn with_origin(inner: T, origin: Uri) -> Self> ``` -------------------------------- ### Get Ipvlan Mode from String Source: https://docs.rs/netavark/1.17.2/netavark/network/core_utils/struct.CoreUtils.html Converts an optional string slice into an IpVlanMode enum variant. Returns an error if the string is invalid. ```rust pub fn get_ipvlan_mode_from_string( mode: Option<&str>, ) -> NetavarkResult ``` -------------------------------- ### Bridge::new Source: https://docs.rs/netavark/1.17.2/netavark/network/bridge/struct.Bridge.html Constructs a new Bridge driver instance. ```APIDOC ## Bridge::new ### Description Initializes a new instance of the Bridge network driver. ### Method `new` ### Parameters #### Path Parameters - **info** (DriverInfo<'a>) - Required - Information required to initialize the driver. ### Response - **Self** - A new Bridge driver instance. ``` -------------------------------- ### Teardown::new Source: https://docs.rs/netavark/1.17.2/netavark/commands/teardown/struct.Teardown.html Constructor for the Teardown command. Initializes a new Teardown instance with the path to the network namespace. ```APIDOC ## Teardown::new ### Description Initializes a new Teardown command instance. This command is the inverse of the setup command, undoing any configuration applied. Note that some interfaces, like bridge interfaces, may not be deleted. ### Signature ```rust pub fn new(network_namespace_path: String) -> Self ``` ### Parameters * **network_namespace_path** (String) - The path to the network namespace to be torn down. ``` -------------------------------- ### Get MacVlan Mode from String Source: https://docs.rs/netavark/1.17.2/netavark/network/core_utils/struct.CoreUtils.html Converts an optional string slice into a MacVlanMode enum variant. Returns an error if the string is invalid. ```rust pub fn get_macvlan_mode_from_string( mode: Option<&str>, ) -> NetavarkResult ``` -------------------------------- ### DhcpV4Service::new Source: https://docs.rs/netavark/1.17.2/netavark/dhcp_proxy/dhcp_service/struct.DhcpV4Service.html Initializes a new DhcpV4Service with network configuration and a timeout. ```APIDOC ## DhcpV4Service::new ### Description Initializes a new DhcpV4Service with the provided network configuration and timeout. ### Signature ```rust pub async fn new(nc: NetworkConfig, timeout: u32) -> Result ``` ### Parameters * `nc`: NetworkConfig - The network configuration to use. * `timeout`: u32 - The timeout value for DHCP operations. ### Returns * `Result` - Ok containing the new DhcpV4Service instance or an Err with DhcpServiceError. ``` -------------------------------- ### Initialize firewalld Firewall Driver Source: https://docs.rs/netavark/1.17.2/netavark/firewall/firewalld/fn.new.html Creates a new instance of the `firewalld` firewall driver. This function requires an active `Connection` object. ```rust pub fn new(conn: Connection) -> Result, NetavarkError> ``` -------------------------------- ### PluginExec::new Constructor Source: https://docs.rs/netavark/1.17.2/netavark/plugin/struct.PluginExec.html Creates a new instance of PluginExec, taking a plugin and its associated info. ```rust pub fn new(plugin: P, info: Info) -> Self ``` -------------------------------- ### LeaseCache::new Source: https://docs.rs/netavark/1.17.2/netavark/dhcp_proxy/cache/struct.LeaseCache.html Initializes a new LeaseCache. It requires a writer that implements the Write and Clear traits, typically a file in production or a Cursor in testing. ```APIDOC ## LeaseCache::new ### Description Initializes a new LeaseCache with a given writer. ### Method `new` ### Arguments * `writer`: Any type that implements `Write` and `Clear` traits. This is typically a file in production or a `Cursor` in development/testing. ### Returns * `Result, Error>`: A new `LeaseCache` instance or an error if initialization fails. ``` -------------------------------- ### Implement Parser for Version Source: https://docs.rs/netavark/1.17.2/netavark/commands/version/struct.Version.html Provides methods for parsing command-line arguments into a Version instance. ```rust fn parse() -> Self Parse from `std::env::args_os()`, exit on error. ``` ```rust fn try_parse() -> Result Parse from `std::env::args_os()`, return Err on error. ``` ```rust fn parse_from(itr: I) -> Self where I: IntoIterator, T: Into + Clone, Parse from iterator, exit on error. ``` ```rust fn try_parse_from(itr: I) -> Result where I: IntoIterator, T: Into + Clone, Parse from iterator, return Err on error. ``` ```rust fn update_from(&mut self, itr: I) where I: IntoIterator, T: Into + Clone, Update from iterator, exit on error. Read more ``` ```rust fn try_update_from(&mut self, itr: I) -> Result<(), Error> where I: IntoIterator, T: Into + Clone, Update from iterator, return Err on error. ``` -------------------------------- ### Implement CommandFactory for Version Source: https://docs.rs/netavark/1.17.2/netavark/commands/version/struct.Version.html Provides methods for building a clap Command that can instantiate the Version struct. ```rust fn command<'b>() -> Command Build a `Command` that can instantiate `Self`. Read more ``` ```rust fn command_for_update<'b>() -> Command Build a `Command` that can update `self`. Read more ``` -------------------------------- ### Check firewalld StrictForwardPorts Enabled Source: https://docs.rs/netavark/1.17.2/netavark/firewall/firewalld/fn.is_firewalld_strict_forward_enabled.html Checks if firewalld's StrictForwardPorts setting is enabled. Returns false if firewalld is not installed, not running, or if there are any errors. ```rust pub fn is_firewalld_strict_forward_enabled( dbus_con: &Option, ) -> bool ``` -------------------------------- ### Create New NetavarkProxyClient Source: https://docs.rs/netavark/1.17.2/netavark/dhcp_proxy/lib/g_rpc/netavark_proxy_client/struct.NetavarkProxyClient.html Constructs a new NetavarkProxyClient with a given inner gRPC service. ```rust pub fn new(inner: T) -> Self> ``` -------------------------------- ### Get Bridge Sysctl Path Source: https://docs.rs/netavark/1.17.2/netavark/network/sysctl/fn.get_bridge_sysctl_d_path.html Returns the sysctl directory path for a specified bridge name. This is useful for dynamically configuring bridge network settings. ```rust pub fn get_bridge_sysctl_d_path(bridge_name: &str) -> String ``` -------------------------------- ### new Source: https://docs.rs/netavark/1.17.2/netavark/firewall/fwnone/fn.new.html Creates a new instance of the FirewallDriver. This function is part of the netavark firewall fwnone module. ```APIDOC ## new ### Description Creates a new instance of the FirewallDriver. ### Signature ```rust pub fn new() -> NetavarkResult> ``` ``` -------------------------------- ### Get Netavark DNS Port Source: https://docs.rs/netavark/1.17.2/netavark/network/core_utils/fn.get_netavark_dns_port.html Call this function to retrieve the current Netavark DNS port. It returns a Result containing the port number or a NetavarkError. ```rust pub fn get_netavark_dns_port() -> Result ``` -------------------------------- ### Get Supported Firewall Driver Source: https://docs.rs/netavark/1.17.2/netavark/firewall/fn.get_supported_firewall_driver.html Call this function to obtain the default firewall driver for the system. An optional driver name can be provided to request a specific driver. ```rust pub fn get_supported_firewall_driver( driver_name: Option, ) -> NetavarkResult> ``` -------------------------------- ### NetavarkProxyServer Constructors Source: https://docs.rs/netavark/1.17.2/netavark/dhcp_proxy/lib/g_rpc/netavark_proxy_server/struct.NetavarkProxyServer.html These functions are used to create new instances of NetavarkProxyServer. ```APIDOC ## `new` ### Description Creates a new `NetavarkProxyServer` with the given inner service. ### Signature `pub fn new(inner: T) -> Self` ``` ```APIDOC ## `from_arc` ### Description Creates a new `NetavarkProxyServer` from an `Arc` containing the inner service. ### Signature `pub fn from_arc(inner: Arc) -> Self` ``` ```APIDOC ## `with_interceptor` ### Description Creates a new `InterceptedService` with the given inner service and an interceptor. ### Signature `pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService` ### Type Parameters * `F`: The type of the interceptor, which must implement the `Interceptor` trait. ``` -------------------------------- ### NetavarkProxyServer Configuration Methods Source: https://docs.rs/netavark/1.17.2/netavark/dhcp_proxy/lib/g_rpc/netavark_proxy_server/struct.NetavarkProxyServer.html These methods allow for configuring the behavior of the NetavarkProxyServer, such as compression and message size limits. ```APIDOC ## `accept_compressed` ### Description Enables decompressing requests with the specified encoding. ### Signature `pub fn accept_compressed(self, encoding: CompressionEncoding) -> Self` ### Parameters * `encoding`: The `CompressionEncoding` to accept. ``` ```APIDOC ## `send_compressed` ### Description Enables compressing responses with the specified encoding, if the client supports it. ### Signature `pub fn send_compressed(self, encoding: CompressionEncoding) -> Self` ### Parameters * `encoding`: The `CompressionEncoding` to use for responses. ``` ```APIDOC ## `max_decoding_message_size` ### Description Limits the maximum size of a decoded message. ### Signature `pub fn max_decoding_message_size(self, limit: usize) -> Self` ### Parameters * `limit`: The maximum size in bytes for decoded messages. ### Default `4MB` ``` ```APIDOC ## `max_encoding_message_size` ### Description Limits the maximum size of an encoded message. ### Signature `pub fn max_encoding_message_size(self, limit: usize) -> Self` ### Parameters * `limit`: The maximum size in bytes for encoded messages. ### Default `usize::MAX` ``` -------------------------------- ### Get string name of Version enum variant Source: https://docs.rs/netavark/1.17.2/netavark/dhcp_proxy/lib/g_rpc/enum.Version.html Returns the string representation of the enum variant, corresponding to its name in the ProtoBuf definition. This is useful for logging or debugging. ```rust pub fn as_str_name(&self) -> &'static str ``` -------------------------------- ### Create New Iptables Firewall Driver Source: https://docs.rs/netavark/1.17.2/netavark/firewall/iptables/fn.new.html Initializes and returns a new instance of the iptables firewall driver. This is the entry point for using the iptables backend. ```rust pub fn new() -> NetavarkResult> ``` -------------------------------- ### NetworkDriver Trait Definition Source: https://docs.rs/netavark/1.17.2/netavark/network/driver/trait.NetworkDriver.html Defines the core methods required for a network driver. Implementors must provide logic for validation, setup, teardown, and returning the network name. ```rust pub trait NetworkDriver { // Required methods fn validate(&mut self) -> NetavarkResult<()>; fn setup( &self, netlink_sockets: (&mut Socket, &mut Socket), ) -> NetavarkResult<(StatusBlock, Option>)>; fn teardown( &self, netlink_sockets: (&mut Socket, &mut Socket), ) -> NetavarkResult<()>; fn network_name(&self) -> String; } ``` -------------------------------- ### load Function Source: https://docs.rs/netavark/1.17.2/netavark/network/types/struct.NetworkOptions.html Loads NetworkOptions from a specified path. ```APIDOC ### impl NetworkOptions #### pub fn load(path: Option) -> NetavarkResult Loads NetworkOptions from a specified path. ``` -------------------------------- ### write_fw_config Function Signature Source: https://docs.rs/netavark/1.17.2/netavark/firewall/state/fn.write_fw_config.html This function signature defines the parameters required to write firewall configurations to disk. It should be called after firewall setup to allow firewalld to reload the rules. ```rust pub fn write_fw_config( config_dir: &Path, network_id: &str, container_id: &str, fw_driver: &str, net_conf: &SetupNetwork, port_conf: &PortForwardConfig<'_>, ) -> NetavarkResult<()> ``` -------------------------------- ### Implement FromArgMatches for Version Source: https://docs.rs/netavark/1.17.2/netavark/commands/version/struct.Version.html Provides methods for creating a Version instance from clap ArgMatches. ```rust fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result Instantiate `Self` from `ArgMatches`, parsing the arguments as needed. Read more ``` ```rust fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result Instantiate `Self` from `ArgMatches`, parsing the arguments as needed. Read more ``` ```rust fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error> Assign values from `ArgMatches` to `self`. ``` ```rust fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error> Assign values from `ArgMatches` to `self`. ``` -------------------------------- ### Load NetworkOptions from File Source: https://docs.rs/netavark/1.17.2/netavark/network/types/struct.NetworkOptions.html Loads NetworkOptions from a specified file path. Returns a NetavarkResult containing the deserialized NetworkOptions or an error. ```rust pub fn load(path: Option) -> NetavarkResult ``` -------------------------------- ### Providing Default Values with `unwrap_or` Source: https://docs.rs/netavark/1.17.2/netavark/error/type.NetavarkResult.html Shows how to get the `Ok` value from a `Result` or use a provided default value if it's an `Err`. Arguments to `unwrap_or` are eagerly evaluated. ```rust let default = 2; let x: Result = Ok(9); assert_eq!(x.unwrap_or(default), 9); let x: Result = Err("error"); assert_eq!(x.unwrap_or(default), default); ``` -------------------------------- ### Implement Args for Version Source: https://docs.rs/netavark/1.17.2/netavark/commands/version/struct.Version.html Provides methods for defining and augmenting command-line arguments related to the Version struct. ```rust fn group_id() -> Option Report the `ArgGroup::id` for this set of arguments ``` ```rust fn augment_args<'b>(__clap_app: Command) -> Command Append to `Command` so it can instantiate `Self` via `FromArgMatches::from_arg_matches_mut` Read more ``` ```rust fn augment_args_for_update<'b>(__clap_app: Command) -> Command Append to `Command` so it can instantiate `self` via `FromArgMatches::update_from_arg_matches_mut` Read more ``` -------------------------------- ### Getting a Mutable Reference to the value Source: https://docs.rs/netavark/1.17.2/netavark/error/type.NetavarkResult.html Use `as_mut()` to convert a `&mut Result` into a `Result<&mut T, &mut E>`. This enables in-place modification of the contained values. ```rust fn mutate(r: &mut Result) { match r.as_mut() { Ok(v) => *v = 42, Err(e) => *e = 0, } } let mut x: Result = Ok(2); mutate(&mut x); assert_eq!(x.unwrap(), 42); let mut x: Result = Err(13); mutate(&mut x); assert_eq!(x.unwrap_err(), 0); ```