pub struct Modem(pub Address);Expand description
The modem component (12 methods).
Provided by OpenComputers’ NetworkCard, WirelessNetworkCard, WirelessNetworkCard$Tier1, WirelessNetworkCard$Tier2.
Tuple Fields§
§0: AddressImplementations§
Source§impl Modem
impl Modem
Sourcepub fn broadcast(&self, port: impl Into<Number>, data: &[Value]) -> Result<()>
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.
Sourcepub async fn broadcast_async(
&self,
port: impl Into<Number>,
data: &[Value],
) -> Result<()>
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.
Sourcepub fn close(&self, port: Option<Number>) -> Result<bool>
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.
Sourcepub async fn close_async(&self, port: Option<Number>) -> Result<bool>
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.
Sourcepub fn get_strength(&self) -> Result<Number>
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).
Sourcepub async fn get_strength_async(&self) -> Result<Number>
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.
Sourcepub fn get_wake_message(&self) -> Result<(OcString, bool)>
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).
Sourcepub async fn get_wake_message_async(&self) -> Result<(OcString, bool)>
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.
Sourcepub fn is_open(&self, port: impl Into<Number>) -> Result<bool>
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).
Sourcepub async fn is_open_async(&self, port: impl Into<Number>) -> Result<bool>
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.
Sourcepub fn is_wired(&self) -> Result<bool>
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).
Sourcepub async fn is_wired_async(&self) -> Result<bool>
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.
Sourcepub fn is_wireless(&self) -> Result<bool>
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).
Sourcepub async fn is_wireless_async(&self) -> Result<bool>
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.
Sourcepub fn max_packet_size(&self) -> Result<Number>
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).
Sourcepub async fn max_packet_size_async(&self) -> Result<Number>
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.
Sourcepub fn open(&self, port: impl Into<Number>) -> Result<bool>
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.
Sourcepub async fn open_async(&self, port: impl Into<Number>) -> Result<bool>
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.
Sourcepub fn send(
&self,
address: impl AsRef<[u8]>,
port: impl Into<Number>,
data: &[Value],
) -> Result<()>
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.
Sourcepub async fn send_async(
&self,
address: impl AsRef<[u8]>,
port: impl Into<Number>,
data: &[Value],
) -> Result<()>
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.
Sourcepub fn set_strength(&self, strength: impl Into<Number>) -> Result<Number>
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.
Sourcepub async fn set_strength_async(
&self,
strength: impl Into<Number>,
) -> Result<Number>
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.
Sourcepub fn set_wake_message(
&self,
message: impl AsRef<[u8]>,
fuzzy: Option<bool>,
) -> Result<OcString>
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.
Sourcepub async fn set_wake_message_async(
&self,
message: impl AsRef<[u8]>,
fuzzy: Option<bool>,
) -> Result<OcString>
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 Component for Modem
impl Component for Modem
Source§fn from_address(address: Address) -> Self
fn from_address(address: Address) -> Self
fn address(&self) -> &Address
Source§fn at(address: impl Into<Address>) -> Option<Self>
fn at(address: impl Into<Address>) -> Option<Self>
address, if it is of this type.Source§fn invoke(&self, method: &str, args: Vec<Value>) -> Result<Vec<Value>>
fn invoke(&self, method: &str, args: Vec<Value>) -> Result<Vec<Value>>
Source§fn invoke_async(&self, method: &str, args: Vec<Value>) -> Call ⓘ
fn invoke_async(&self, method: &str, args: Vec<Value>) -> Call ⓘ
Component::invoke without blocking; see invoke_async.