pub struct NetworkConfig {
pub name: String,
pub subnet: String,
pub gateway: Ipv4Addr,
pub driver: String,
pub labels: HashMap<String, String>,
pub endpoints: HashMap<String, NetworkEndpoint>,
pub created_at: String,
pub policy: NetworkPolicy,
}Expand description
Configuration for a user-defined network.
Fields§
§name: StringNetwork name (unique identifier).
subnet: StringSubnet in CIDR notation (e.g., “10.88.0.0/24”).
gateway: Ipv4AddrGateway IP address (e.g., “10.88.0.1”).
driver: StringNetwork driver (currently only “bridge” is supported).
labels: HashMap<String, String>User-defined labels.
endpoints: HashMap<String, NetworkEndpoint>Connected endpoints (box_id → endpoint).
created_at: StringCreation timestamp (RFC 3339).
policy: NetworkPolicyNetwork isolation policy.
Implementations§
Source§impl NetworkConfig
impl NetworkConfig
Sourcepub fn new(name: &str, subnet: &str) -> Result<Self, String>
pub fn new(name: &str, subnet: &str) -> Result<Self, String>
Create a new network with the given name and subnet.
Sourcepub fn connect(
&mut self,
box_id: &str,
box_name: &str,
) -> Result<NetworkEndpoint, String>
pub fn connect( &mut self, box_id: &str, box_name: &str, ) -> Result<NetworkEndpoint, String>
Allocate an IP and register a new endpoint for a box.
Sourcepub fn disconnect(&mut self, box_id: &str) -> Result<NetworkEndpoint, String>
pub fn disconnect(&mut self, box_id: &str) -> Result<NetworkEndpoint, String>
Remove a box from this network.
Sourcepub fn set_policy(&mut self, policy: NetworkPolicy) -> Result<(), String>
pub fn set_policy(&mut self, policy: NetworkPolicy) -> Result<(), String>
Set the network policy, validating that it can be enforced.
Returns an error if the policy uses an isolation mode that is not yet implemented at the packet-filtering level.
Sourcepub fn connected_boxes(&self) -> Vec<&NetworkEndpoint>
pub fn connected_boxes(&self) -> Vec<&NetworkEndpoint>
Get all connected endpoints.
Trait Implementations§
Source§impl Clone for NetworkConfig
impl Clone for NetworkConfig
Source§fn clone(&self) -> NetworkConfig
fn clone(&self) -> NetworkConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for NetworkConfig
impl Debug for NetworkConfig
Source§impl<'de> Deserialize<'de> for NetworkConfig
impl<'de> Deserialize<'de> for NetworkConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for NetworkConfig
impl RefUnwindSafe for NetworkConfig
impl Send for NetworkConfig
impl Sync for NetworkConfig
impl Unpin for NetworkConfig
impl UnsafeUnpin for NetworkConfig
impl UnwindSafe for NetworkConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more