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 validate_runtime(&self) -> Result<(), String>
pub fn validate_runtime(&self) -> Result<(), String>
Validate the driver and policy that the runtime can enforce today.
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 connect_with_aliases(
&mut self,
box_id: &str,
box_name: &str,
aliases: &[String],
) -> Result<NetworkEndpoint, String>
pub fn connect_with_aliases( &mut self, box_id: &str, box_name: &str, aliases: &[String], ) -> Result<NetworkEndpoint, String>
Connect a box, also registering extra DNS aliases that resolve to its IP (e.g. the bare Compose service name in addition to the box name).
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
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more