From b9b8d6baf902c9f589eef77c6b1c26401994140b Mon Sep 17 00:00:00 2001 From: Jhynjhiruu Date: Tue, 9 Apr 2024 15:51:40 +0100 Subject: [PATCH] Fix nits --- ctru-rs/examples/local-networking.rs | 10 +++++----- ctru-rs/src/services/uds.rs | 22 ++++++++++------------ 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/ctru-rs/examples/local-networking.rs b/ctru-rs/examples/local-networking.rs index 3871a1a..10467d5 100644 --- a/ctru-rs/examples/local-networking.rs +++ b/ctru-rs/examples/local-networking.rs @@ -7,7 +7,7 @@ use ctru::services::uds::*; fn handle_status_event(uds: &Uds, prev_node_mask: u16) -> ctru::Result { println!("Connection status event signalled"); - let status = uds.get_connection_status()?; + let status = uds.connection_status()?; println!("Status: {status:#02X?}"); let left = prev_node_mask & (status.node_bitmask() ^ prev_node_mask); let joined = status.node_bitmask() & (status.node_bitmask() ^ prev_node_mask); @@ -21,7 +21,7 @@ fn handle_status_event(uds: &Uds, prev_node_mask: u16) -> ctru::Result { println!( "Node {} connected: {:?}", i + 1, - uds.get_node_info(NodeID::Node(i + 1)) + uds.node_info(NodeID::Node(i + 1)) ); } } @@ -153,7 +153,7 @@ fn main() -> Result<(), Error> { } } State::Connect => { - let appdata = uds.get_network_appdata(&networks[selected_network], None)?; + let appdata = uds.network_appdata(&networks[selected_network], None)?; println!("App data: {:02X?}", appdata); if let Err(e) = uds.connect_network( @@ -167,10 +167,10 @@ fn main() -> Result<(), Error> { state = State::Initialised; println!("Press A to start scanning or B to create a new network"); } else { - channel = uds.get_channel()?; + channel = uds.channel()?; println!("Connected using channel {}", channel); - let appdata = uds.get_appdata(None)?; + let appdata = uds.appdata(None)?; println!("App data: {:02X?}", appdata); if uds.wait_status_event(false, false)? { diff --git a/ctru-rs/src/services/uds.rs b/ctru-rs/src/services/uds.rs index 1ec7407..58c7e4f 100644 --- a/ctru-rs/src/services/uds.rs +++ b/ctru-rs/src/services/uds.rs @@ -569,13 +569,13 @@ impl Uds { /// let mut uds = Uds::new(None)?; /// /// let networks = uds.scan(b"HBW\x10", None, None)?; - /// let appdata = uds.get_network_appdata(&networks[0], None)?; + /// let appdata = uds.network_appdata(&networks[0], None)?; /// # /// # Ok(()) /// # } /// ``` #[doc(alias = "udsGetNetworkStructApplicationData")] - pub fn get_network_appdata( + pub fn network_appdata( &self, network: &NetworkScanInfo, max_size: Option, @@ -625,13 +625,13 @@ impl Uds { /// /// let networks = uds.scan(b"HBW\x10", None, None)?; /// uds.connect_network(&networks[0], b"udsdemo passphrase c186093cd2652741\0", ConnectionType::Client, 1)?; - /// let appdata = uds.get_appdata(None)?; + /// let appdata = uds.appdata(None)?; /// # /// # Ok(()) /// # } /// ``` #[doc(alias = "udsGetApplicationData")] - pub fn get_appdata(&self, max_size: Option) -> Result, Error> { + pub fn appdata(&self, max_size: Option) -> Result, Error> { if self.service_status() == ServiceStatus::Disconnected { return Err(Error::NotConnected); } @@ -807,13 +807,13 @@ impl Uds { /// /// let networks = uds.scan(b"HBW\x10", None, None)?; /// uds.connect_network(&networks[0], b"udsdemo passphrase c186093cd2652741\0", ConnectionType::Client, 1)?; - /// let channel = uds.get_channel()?; + /// let channel = uds.channel()?; /// # /// # Ok(()) /// # } /// ``` #[doc(alias = "udsGetChannel")] - pub fn get_channel(&self) -> Result { + pub fn channel(&self) -> Result { if self.service_status() == ServiceStatus::Disconnected { return Err(Error::NotConnected); } @@ -870,8 +870,6 @@ impl Uds { /// Returns the current [`ConnectionStatus`] struct. /// - /// TODO: should this return an error if not connected? - /// /// # Example /// /// ``` @@ -886,7 +884,7 @@ impl Uds { /// uds.connect_network(&networks[0], b"udsdemo passphrase c186093cd2652741\0", ConnectionType::Client, 1)?; /// if uds.wait_status_event(false, false)? { /// println!("Connection status event signalled"); - /// let status = uds.get_connection_status()?; + /// let status = uds.connection_status()?; /// println!("Status: {status:#X?}"); /// } /// # @@ -894,7 +892,7 @@ impl Uds { /// # } /// ``` #[doc(alias = "udsGetConnectionStatus")] - pub fn get_connection_status(&self) -> crate::Result { + pub fn connection_status(&self) -> crate::Result { let mut status = MaybeUninit::uninit(); ResultCode(unsafe { ctru_sys::udsGetConnectionStatus(status.as_mut_ptr()) })?; @@ -1350,13 +1348,13 @@ impl Uds { /// let mut uds = Uds::new(None)?; /// /// uds.create_network(b"HBW\x10", None, None, b"udsdemo passphrase c186093cd2652741\0", 1)?; - /// let node_info = uds.get_node_info(NodeID::Node(2))?; + /// let node_info = uds.node_info(NodeID::Node(2))?; /// # /// # Ok(()) /// # } /// ``` #[doc(alias = "udsGetNodeInformation")] - pub fn get_node_info(&self, address: NodeID) -> Result { + pub fn node_info(&self, address: NodeID) -> Result { let NodeID::Node(node) = address else { return Err(Error::NotANode); };