pub struct BridgeHostState { /* private fields */ }Expand description
The state of bridges that are actively known on this host.
This is effectively just a list of bridges along with one of those being
set as the “default” bridge. A lot of this configuration is stored within
a system level directory, see BridgeHostState::get_default_host_path.
Implementations§
Source§impl BridgeHostState
impl BridgeHostState
Sourcepub async fn load() -> Result<Self, FSError>
pub async fn load() -> Result<Self, FSError>
Attempt to load the bridge host state from the filesystem.
This is commonly referred to as bridge_env.ini, stored normally in
Windows under the %APPDATA%\bridge_env.ini file. This is where tools
like getbridge/hostdisplayversion/setbridge store which bridges
you actually use, and which one you’ve set as the default bridge.
§Errors
- If we cannot get the default host path for your OS.
- Any error case from
BridgeHostState::load_explicit_path.
Sourcepub async fn load_explicit_path(path: PathBuf) -> Result<Self, FSError>
pub async fn load_explicit_path(path: PathBuf) -> Result<Self, FSError>
Attempt to load the bridge host state file from the filesystem.
This is commonly referred to as bridge_env.ini, and is a small
Windows (so UTF8) ini file, separated by newlines being \r\n.
§Errors
- If we cannot read from the file on the file system.
- If we cannot parse the data in the file as UTF8.
- If we cannot parse the data as an INI file.
Sourcepub fn get_default_bridge(&self) -> Option<(String, Option<Ipv4Addr>)>
pub fn get_default_bridge(&self) -> Option<(String, Option<Ipv4Addr>)>
Grab the currently configured default host bridge.
This returns an option (representing if any default has been configured), and then will return an option for the ip address as the name could potentially point to a name that doesn’t have an ip address set, or one that doesn’t have a valid IPv4 address (as bridges are required to be IPv4).
Sourcepub fn get_bridge(&self, bridge_name: &str) -> Option<(Option<Ipv4Addr>, bool)>
pub fn get_bridge(&self, bridge_name: &str) -> Option<(Option<Ipv4Addr>, bool)>
Get an actively configured bridge.
Returns (BridgeIP, IsDefault), if a bridge is actively configured.
Sourcepub fn list_bridges(&self) -> FnvHashMap<String, (Option<Ipv4Addr>, bool)>
pub fn list_bridges(&self) -> FnvHashMap<String, (Option<Ipv4Addr>, bool)>
List all the bridges that are actively configured.
Returns a map of <BridgeName, (BridgeIP, IsDefault)>. The Bridge IP
will be an empty option if we could not parse the value as an IPv4
Address (i.e. the value is invalid), or the key did not have a value.
Sourcepub fn upsert_bridge(
&mut self,
bridge_name: &str,
bridge_ip: Ipv4Addr,
) -> Result<(), MIONAPIError>
pub fn upsert_bridge( &mut self, bridge_name: &str, bridge_ip: Ipv4Addr, ) -> Result<(), MIONAPIError>
Insert a new bridge, or update it’s value.
note: this will be visible in memory immediately, but in order to
persist it, or have it seen in another process you need to call
BridgeHostState::write_to_disk.
§Errors
If the bridge name is not ascii. If the bridge name is empty. If the bridge name is too long.
Sourcepub fn remove_bridge(&mut self, bridge_name: &str)
pub fn remove_bridge(&mut self, bridge_name: &str)
Remove a bridge from the configuration file.
note: this will be visible in memory immediately, but in order to
persist it, or have it seen in another process you need to call
BridgeHostState::write_to_disk.
Sourcepub fn remove_default_bridge(&mut self)
pub fn remove_default_bridge(&mut self)
Remove the default bridge key from the configuration file.
note: this will be visible in memory immediately, but in order to
persist it, or have it seen in another process you need to call
BridgeHostState::write_to_disk.
Sourcepub fn set_default_bridge(
&mut self,
bridge_name: &str,
) -> Result<(), MIONAPIError>
pub fn set_default_bridge( &mut self, bridge_name: &str, ) -> Result<(), MIONAPIError>
Set the default bridge for your host.
§Errors
If you try setting the default bridge to a bridge that does not exist. If your device name is not ascii. If your device name is empty. If your device name is too long.
Sourcepub async fn write_to_disk(&self) -> Result<(), FSError>
pub async fn write_to_disk(&self) -> Result<(), FSError>
Write the current configuration to disk as a Windows INI file.
We always write the file with carriage returns \r\n (windows line
endings), and in UTF-8. So we can always copy-paste the file onto
a windows host and have it be read by the official tools without issue.
§Errors
If we run into a system error when writing the file to the disk.
Sourcepub fn get_path(&self) -> &PathBuf
pub fn get_path(&self) -> &PathBuf
Get the path the Bridge Host State file was being loaded from.
Sourcepub fn get_default_host_path() -> Option<PathBuf>
pub fn get_default_host_path() -> Option<PathBuf>
Get the default path that the bridge host state is supposed to be stored in.
NOTE: this directory is not necissarily guaranteed to exist.
Returns none when we can’t find an appropriate path to store bridge host state in.
Trait Implementations§
Source§impl Clone for BridgeHostState
impl Clone for BridgeHostState
Source§fn clone(&self) -> BridgeHostState
fn clone(&self) -> BridgeHostState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BridgeHostState
impl Debug for BridgeHostState
Source§impl PartialEq for BridgeHostState
impl PartialEq for BridgeHostState
impl Eq for BridgeHostState
impl StructuralPartialEq for BridgeHostState
Auto Trait Implementations§
impl Freeze for BridgeHostState
impl RefUnwindSafe for BridgeHostState
impl Send for BridgeHostState
impl Sync for BridgeHostState
impl Unpin for BridgeHostState
impl UnwindSafe for BridgeHostState
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
self to key and returns true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more