Struct ctru::services::soc::Soc

source ·
pub struct Soc { /* private fields */ }
Expand description

Handle to the Network Socket service.

Implementations§

source§

impl Soc

source

pub fn new() -> Result<Self>

Initialize a new service handle using a socket buffer size of 0x100000 bytes.

§Errors

This function will return an error if the Soc service is already being used.

§Example
use ctru::services::soc::Soc;

let soc = Soc::new()?;
source

pub fn init_with_buffer_size(num_bytes: usize) -> Result<Self>

Initialize a new service handle using a custom socket buffer size.

The size should be 0x100000 bytes or greater.

§Errors

This function will return an error if the Soc service is already being used.

§Example
use ctru::services::soc::Soc;

let soc = Soc::init_with_buffer_size(0x100000)?;
source

pub fn host_address(&self) -> Ipv4Addr

Returns the local IP Address of the Nintendo 3DS system.

§Example
use ctru::services::soc::Soc;
let soc = Soc::new()?;

let address = soc.host_address();

Redirect output streams (i.e. stdout and stderr) to the 3dslink server.

With this redirection it is possible to send (and view in real time) the output of stdout operations, such as println! or dbg!.

Requires 3dslink >= 0.6.1 and new-hbmenu >= 2.3.0 and the use of the --server flag. The --server flag is also availble to use via cargo-3ds if the requirements are met.

§Errors

Returns an error if a connection cannot be established to the server, or if the output was already being redirected.

§Example
use ctru::services::soc::Soc;
let mut soc = Soc::new()?;

// Redirect to the `3dslink` server that sent this program.
let address = soc.redirect_to_3dslink(true, true)?;

println!("I'm visible from a PC!");

Trait Implementations§

source§

impl Drop for Soc

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Soc

§

impl !Send for Soc

§

impl Sync for Soc

§

impl Unpin for Soc

§

impl !UnwindSafe for Soc

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.