Browse Source

Fix nits

pull/156/head
Jhynjhiruu 9 months ago
parent
commit
b9b8d6baf9
  1. 10
      ctru-rs/examples/local-networking.rs
  2. 22
      ctru-rs/src/services/uds.rs

10
ctru-rs/examples/local-networking.rs

@ -7,7 +7,7 @@ use ctru::services::uds::*; @@ -7,7 +7,7 @@ use ctru::services::uds::*;
fn handle_status_event(uds: &Uds, prev_node_mask: u16) -> ctru::Result<u16> {
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<u16> { @@ -21,7 +21,7 @@ fn handle_status_event(uds: &Uds, prev_node_mask: u16) -> ctru::Result<u16> {
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> { @@ -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> { @@ -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)? {

22
ctru-rs/src/services/uds.rs

@ -569,13 +569,13 @@ impl Uds { @@ -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<usize>,
@ -625,13 +625,13 @@ impl Uds { @@ -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<usize>) -> Result<Vec<u8>, Error> {
pub fn appdata(&self, max_size: Option<usize>) -> Result<Vec<u8>, Error> {
if self.service_status() == ServiceStatus::Disconnected {
return Err(Error::NotConnected);
}
@ -807,13 +807,13 @@ impl Uds { @@ -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<u8, Error> {
pub fn channel(&self) -> Result<u8, Error> {
if self.service_status() == ServiceStatus::Disconnected {
return Err(Error::NotConnected);
}
@ -870,8 +870,6 @@ impl Uds { @@ -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 { @@ -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 { @@ -894,7 +892,7 @@ impl Uds {
/// # }
/// ```
#[doc(alias = "udsGetConnectionStatus")]
pub fn get_connection_status(&self) -> crate::Result<ConnectionStatus> {
pub fn connection_status(&self) -> crate::Result<ConnectionStatus> {
let mut status = MaybeUninit::uninit();
ResultCode(unsafe { ctru_sys::udsGetConnectionStatus(status.as_mut_ptr()) })?;
@ -1350,13 +1348,13 @@ impl Uds { @@ -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<NodeInfo, Error> {
pub fn node_info(&self, address: NodeID) -> Result<NodeInfo, Error> {
let NodeID::Node(node) = address else {
return Err(Error::NotANode);
};

Loading…
Cancel
Save