|
1 | 1 | use std::{fmt, io::BufRead, net::IpAddr, sync::Arc};
|
2 | 2 |
|
3 | 3 | use crate::{
|
4 |
| - core::{env, error::Result, ports::Ports, ContainerPort, ExecCommand}, |
| 4 | + core::{env, error::Result, network::Network, ports::Ports, ContainerPort, ExecCommand}, |
5 | 5 | ContainerAsync, Image,
|
6 | 6 | };
|
7 | 7 |
|
@@ -64,6 +64,44 @@ impl<I> Container<I>
|
64 | 64 | where
|
65 | 65 | I: Image,
|
66 | 66 | {
|
| 67 | + // /// Removes the container. |
| 68 | + // pub fn rm(mut self) -> Result<()> { |
| 69 | + // if let Some(active) = self.inner.take() { |
| 70 | + // active.runtime.block_on(active.async_impl.rm())?; |
| 71 | + // } |
| 72 | + // Ok(()) |
| 73 | + // } |
| 74 | + |
| 75 | + /// Connect the container to `network`. |
| 76 | + pub fn connect(&mut self, network: Option<Arc<Network>>) -> Result<()> { |
| 77 | + if let Some(mut active) = self.inner.take() { |
| 78 | + active |
| 79 | + .runtime |
| 80 | + .block_on(active.async_impl.connect(network))?; |
| 81 | + } |
| 82 | + Ok(()) |
| 83 | + } |
| 84 | + |
| 85 | + /// Disconnect the container from the network `name`. |
| 86 | + pub fn disconnect(&mut self, name: &str) -> Result<()> { |
| 87 | + if let Some(mut active) = self.inner.take() { |
| 88 | + active |
| 89 | + .runtime |
| 90 | + .block_on(active.async_impl.disconnect(name))?; |
| 91 | + } |
| 92 | + Ok(()) |
| 93 | + } |
| 94 | + |
| 95 | + /// Force the container to disconnect from the network `ǹame` |
| 96 | + pub fn force_disconnect(&mut self, name: &str) -> Result<()> { |
| 97 | + if let Some(mut active) = self.inner.take() { |
| 98 | + active |
| 99 | + .runtime |
| 100 | + .block_on(active.async_impl.force_disconnect(name))?; |
| 101 | + } |
| 102 | + Ok(()) |
| 103 | + } |
| 104 | + |
67 | 105 | /// Returns the id of this container.
|
68 | 106 | pub fn id(&self) -> &str {
|
69 | 107 | self.async_impl().id()
|
|
0 commit comments