pub struct Internet(pub Address);Expand description
The internet component (4 methods).
Provided by OpenComputers’ InternetCard.
Tuple Fields§
§0: AddressImplementations§
Source§impl Internet
impl Internet
Sourcepub fn connect(
&self,
address: impl AsRef<[u8]>,
port: Option<Number>,
) -> Result<Handle>
pub fn connect( &self, address: impl AsRef<[u8]>, port: Option<Number>, ) -> Result<Handle>
Opens a new TCP connection. Returns the handle of the connection.
Lua: internet.connect(address:string[, port:number]):userdata
Indirect call: waits for the next server tick.
Sourcepub async fn connect_async(
&self,
address: impl AsRef<[u8]>,
port: Option<Number>,
) -> Result<Handle>
pub async fn connect_async( &self, address: impl AsRef<[u8]>, port: Option<Number>, ) -> Result<Handle>
Self::connect without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn is_http_enabled(&self) -> Result<bool>
pub fn is_http_enabled(&self) -> Result<bool>
Returns whether HTTP requests can be made (config setting).
Lua: internet.isHttpEnabled():boolean
Direct call (runs immediately, drawing on the per-tick budget).
Sourcepub async fn is_http_enabled_async(&self) -> Result<bool>
pub async fn is_http_enabled_async(&self) -> Result<bool>
Self::is_http_enabled without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn is_tcp_enabled(&self) -> Result<bool>
pub fn is_tcp_enabled(&self) -> Result<bool>
Returns whether TCP connections can be made (config setting).
Lua: internet.isTcpEnabled():boolean
Direct call (runs immediately, drawing on the per-tick budget).
Sourcepub async fn is_tcp_enabled_async(&self) -> Result<bool>
pub async fn is_tcp_enabled_async(&self) -> Result<bool>
Self::is_tcp_enabled without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn request(
&self,
url: impl AsRef<[u8]>,
post_data: Option<&str>,
headers: Option<Value>,
method: Option<&str>,
) -> Result<Handle>
pub fn request( &self, url: impl AsRef<[u8]>, post_data: Option<&str>, headers: Option<Value>, method: Option<&str>, ) -> Result<Handle>
Starts an HTTP request. If this returns true, further results will be pushed using http_response signals.
Lua: internet.request(url:string[, postData:string[, headers:table[, method:string]]]):userdata
Indirect call: waits for the next server tick.
Sourcepub async fn request_async(
&self,
url: impl AsRef<[u8]>,
post_data: Option<&str>,
headers: Option<Value>,
method: Option<&str>,
) -> Result<Handle>
pub async fn request_async( &self, url: impl AsRef<[u8]>, post_data: Option<&str>, headers: Option<Value>, method: Option<&str>, ) -> Result<Handle>
Self::request 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 Internet
impl Component for Internet
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.