Skip to main content

Modem

Struct Modem 

Source
pub struct Modem(pub Address);
Expand description

The modem component (12 methods).

Provided by OpenComputers’ NetworkCard, WirelessNetworkCard, WirelessNetworkCard$Tier1, WirelessNetworkCard$Tier2.

Tuple Fields§

§0: Address

Implementations§

Source§

impl Modem

Source

pub fn broadcast(&self, port: impl Into<Number>, data: &[Value]) -> Result<()>

Broadcasts the specified data on the specified port.

Lua: modem.broadcast(port:number, data...) Indirect call: waits for the next server tick.

Source

pub async fn broadcast_async( &self, port: impl Into<Number>, data: &[Value], ) -> Result<()>

Self::broadcast without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn close(&self, port: Option<Number>) -> Result<bool>

Closes the specified port (default: all ports). Returns true if ports were closed.

Lua: modem.close([port:number]):boolean Indirect call: waits for the next server tick.

Source

pub async fn close_async(&self, port: Option<Number>) -> Result<bool>

Self::close without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn get_strength(&self) -> Result<Number>

Get the signal strength (range) used when sending messages.

Lua: modem.getStrength():number Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn get_strength_async(&self) -> Result<Number>

Self::get_strength without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn get_wake_message(&self) -> Result<(OcString, bool)>

Get the current wake-up message.

Lua: modem.getWakeMessage():string, boolean Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn get_wake_message_async(&self) -> Result<(OcString, bool)>

Self::get_wake_message without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn is_open(&self, port: impl Into<Number>) -> Result<bool>

Whether the specified port is open.

Lua: modem.isOpen(port:number):boolean Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn is_open_async(&self, port: impl Into<Number>) -> Result<bool>

Self::is_open without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn is_wired(&self) -> Result<bool>

Whether this card has wired networking capability.

Lua: modem.isWired():boolean Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn is_wired_async(&self) -> Result<bool>

Self::is_wired without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn is_wireless(&self) -> Result<bool>

Whether this card has wireless networking capability.

Lua: modem.isWireless():boolean Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn is_wireless_async(&self) -> Result<bool>

Self::is_wireless without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn max_packet_size(&self) -> Result<Number>

Gets the maximum packet size (config setting).

Lua: modem.maxPacketSize():number Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn max_packet_size_async(&self) -> Result<Number>

Self::max_packet_size without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn open(&self, port: impl Into<Number>) -> Result<bool>

Opens the specified port. Returns true if the port was opened.

Lua: modem.open(port:number):boolean Indirect call: waits for the next server tick.

Source

pub async fn open_async(&self, port: impl Into<Number>) -> Result<bool>

Self::open without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn send( &self, address: impl AsRef<[u8]>, port: impl Into<Number>, data: &[Value], ) -> Result<()>

Sends the specified data.

Lua: modem.send(address:string, port:number, data...) Indirect call: waits for the next server tick.

Source

pub async fn send_async( &self, address: impl AsRef<[u8]>, port: impl Into<Number>, data: &[Value], ) -> Result<()>

Self::send without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn set_strength(&self, strength: impl Into<Number>) -> Result<Number>

Set the signal strength (range) used when sending messages.

Lua: modem.setStrength(strength:number):number Indirect call: waits for the next server tick.

Source

pub async fn set_strength_async( &self, strength: impl Into<Number>, ) -> Result<Number>

Self::set_strength without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn set_wake_message( &self, message: impl AsRef<[u8]>, fuzzy: Option<bool>, ) -> Result<OcString>

Set the wake-up message and whether to ignore additional data/parameters.

Lua: modem.setWakeMessage(message:string[, fuzzy:boolean]):string Indirect call: waits for the next server tick.

Source

pub async fn set_wake_message_async( &self, message: impl AsRef<[u8]>, fuzzy: Option<bool>, ) -> Result<OcString>

Self::set_wake_message without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Trait Implementations§

Source§

impl Clone for Modem

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Component for Modem

Source§

const KIND: &'static str = "modem"

The OpenComputers component type, such as "gpu".
Source§

fn from_address(address: Address) -> Self

Wraps an address without checking what is there.
Source§

fn address(&self) -> &Address

Source§

fn first() -> Option<Self>

The first component of this type, by address order.
Source§

fn all() -> Vec<Self>

Every component of this type, by address order.
Source§

fn at(address: impl Into<Address>) -> Option<Self>

The component at address, if it is of this type.
Source§

fn invoke(&self, method: &str, args: Vec<Value>) -> Result<Vec<Value>>

An untyped call, for methods the wrapper doesn’t know.
Source§

fn invoke_async(&self, method: &str, args: Vec<Value>) -> Call ⓘ

Component::invoke without blocking; see invoke_async.
Source§

impl Debug for Modem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Modem

Source§

impl Hash for Modem

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Modem

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Modem

Auto Trait Implementations§

§

impl Forget for Modem

§

impl Freeze for Modem

§

impl Move for Modem

§

impl RefUnwindSafe for Modem

§

impl Send for Modem

§

impl Sync for Modem

§

impl Unpin for Modem

§

impl UnsafeUnpin for Modem

§

impl UnwindSafe for Modem

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.