Implement From trait for MappedPort to facilitate conversions between tuple and pb_shared::MappedPort
This commit is contained in:
parent
a2899ba5a2
commit
6e1b185383
@ -256,6 +256,21 @@ impl From<Resource> for pb_shared::Resource {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<(u16, u16)> for pb_shared::MappedPort {
|
||||
fn from(val: (u16, u16)) -> Self {
|
||||
Self {
|
||||
host_port: val.0 as u32,
|
||||
container_port: val.1 as u32,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<pb_shared::MappedPort> for (u16, u16) {
|
||||
fn from(val: pb_shared::MappedPort) -> Self {
|
||||
(val.host_port as u16, val.container_port as u16)
|
||||
}
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn from_path(path: &str) -> Result<Self, Box<dyn std::error::Error>> {
|
||||
let config_str = std::fs::read_to_string(path)?;
|
||||
|
Loading…
Reference in New Issue
Block a user