Skip to content

Commit 691ffc2

Browse files
committed
docs: add docs to the new connect/disconnect/alias features
1 parent c24bce6 commit 691ffc2

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

testcontainers/src/core/containers/async_container.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,16 @@ where
7171
Ok(container)
7272
}
7373

74-
pub async fn connect(&mut self, net: Option<Arc<Network>>) -> Result<()> {
74+
/// Connect the container to `network`.
75+
pub async fn connect(&mut self, network: Option<Arc<Network>>) -> Result<()> {
7576
let container_id = self.id().into();
76-
let net = if let Some(net) = net {
77-
net
77+
let network = if let Some(network) = network {
78+
network
7879
} else {
7980
return Ok(());
8081
};
8182

82-
let net_aliases_vec = net.aliases.clone().into_iter().collect();
83+
let net_aliases_vec = network.aliases.clone().into_iter().collect();
8384
let endpoint_settings = EndpointSettings {
8485
aliases: Some(net_aliases_vec),
8586
..Default::default()
@@ -91,13 +92,14 @@ where
9192
};
9293
self.docker_client
9394
.bollard
94-
.connect_network(&net.name, bollard_netword_connect_request)
95+
.connect_network(&network.name, bollard_netword_connect_request)
9596
.await
9697
.map_err(|err| TestcontainersError::Client(ClientError::ConnectionError(err)))?;
9798

9899
Ok(())
99100
}
100101

102+
/// Disconnect the container from the network `name`.
101103
pub async fn disconnect(&mut self, name: &str) -> Result<()> {
102104
let container_id = self.id().into();
103105
let network_disconnect_request = NetworkDisconnectRequest {
@@ -113,6 +115,7 @@ where
113115
Ok(())
114116
}
115117

118+
/// Force the container to disconnect from the network `ǹame`
116119
pub async fn force_disconnect(&mut self, name: &str) -> Result<()> {
117120
let container_id = self.id().into();
118121
let network_disconnect_request = NetworkDisconnectRequest {

testcontainers/src/core/image/image_ext.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub trait ImageExt<I: Image> {
6969
/// Sets the network the container will be connected to.
7070
fn with_network(self, network: impl Into<String>) -> ContainerRequest<I>;
7171

72-
// Adds the specified network alias to the container.
72+
/// Add the specified network alias to the container.
7373
fn with_net_alias(self, network_alias: impl Into<String>) -> ContainerRequest<I>;
7474

7575
/// Adds the specified label to the container.
@@ -252,6 +252,7 @@ impl<RI: Into<ContainerRequest<I>>, I: Image> ImageExt<I> for RI {
252252
}
253253
}
254254

255+
/// Add the specified network alias to the container.
255256
fn with_net_alias(self, network_alias: impl Into<String>) -> ContainerRequest<I> {
256257
let mut container_req = self.into();
257258
container_req.network_aliases.insert(network_alias.into());

0 commit comments

Comments
 (0)