diff --git a/README.md b/README.md index be8b034..5b87034 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,14 @@ API client library for the Compal CH7465LG, which is a cable modem provided by v For more information, see the crate documentation. +## Shell +There is a very work-in-progress shell available in the connectbox-shell crate in this repository. I will include more information about it once it's in a usable state. + +### IPv6 Notice +I am running my modem in the IPv4 mode, so the options available to me are different than what IPv6 mode users see. Thus, this crate will likely not work correctly with IPv6 mode Connect Boxes. + +I am always grateful for any contributions adding IPv6 support, though. + ### Credits Special thanks to the authors of the following projects: * [home-assistant-ecosystem/python-connect-box](https://github.com/home-assistant-ecosystem/python-connect-box) diff --git a/connectbox/src/error.rs b/connectbox/src/error.rs index 0ec5eee..6dbd253 100644 --- a/connectbox/src/error.rs +++ b/connectbox/src/error.rs @@ -1,6 +1,6 @@ use thiserror::Error; -/// The error type used globally by the library. +/// The error type used globally by the library #[derive(Error, Debug)] pub enum Error { #[error("session token not found, are you logged in?")] diff --git a/connectbox/src/lib.rs b/connectbox/src/lib.rs index 2a2ef21..5b980b2 100644 --- a/connectbox/src/lib.rs +++ b/connectbox/src/lib.rs @@ -15,7 +15,7 @@ use serde::de::DeserializeOwned; mod error; mod functions; -/// Data structures used by the library. +/// Data structures used by the library pub mod models; /// A Result type based on the library's Error @@ -167,7 +167,7 @@ impl ConnectBox { Ok(()) } - /// Login to the router. This method must be called before using the client. + /// Log in to the router. This method must be called before using the client. pub async fn login(&self) -> Result<()> { // get the session cookie self.http @@ -178,7 +178,7 @@ impl ConnectBox { self._login().await } - /// Logout of the router. + /// Log out of the router. /// /// The Connect Box allows only one session at a time, thus you should call this method after you're done with using the client, so that other users can log in. pub async fn logout(&self) -> Result<()> { @@ -201,6 +201,8 @@ impl ConnectBox { } /// Toggle or remove port forwards. + /// + /// This function accepts a predicate that will be called for every existing port forward. It should decide what to do with each port forward and return a [`PortForwardAction`]. pub async fn edit_port_forwards(&self, mut f: F) -> Result<()> where F: FnMut(models::PortForwardEntry) -> PortForwardAction, @@ -276,10 +278,15 @@ impl ConnectBox { } } +/// Specifies the action to perform with a given port forward. Used in conjunction with [`ConnectBox::edit_port_forwards`] pub enum PortForwardAction { + /// Don't do anything with the port forward Keep, + /// Enable the port forward Enable, + /// Disable the port forward Disable, + /// Delete the port forward Delete, }