pub struct Data(pub Address);Expand description
The data component (16 methods).
Provided by OpenComputers’ DataCard, DataCard$Tier1, DataCard$Tier2, DataCard$Tier3.
Tuple Fields§
§0: AddressImplementations§
Source§impl Data
impl Data
Sourcepub fn crc32(&self, data: impl AsRef<[u8]>) -> Result<OcString>
pub fn crc32(&self, data: impl AsRef<[u8]>) -> Result<OcString>
Computes CRC-32 hash of the data. Result is binary data.
Lua: data.crc32(data:string):string
Direct call (runs immediately, drawing on the per-tick budget; OC’s limit 32).
Sourcepub async fn crc32_async(&self, data: impl AsRef<[u8]>) -> Result<OcString>
pub async fn crc32_async(&self, data: impl AsRef<[u8]>) -> Result<OcString>
Self::crc32 without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn decode64(&self, data: impl AsRef<[u8]>) -> Result<OcString>
pub fn decode64(&self, data: impl AsRef<[u8]>) -> Result<OcString>
Applies base64 decoding to the data.
Lua: data.decode64(data:string):string
Direct call (runs immediately, drawing on the per-tick budget; OC’s limit 32).
Sourcepub async fn decode64_async(&self, data: impl AsRef<[u8]>) -> Result<OcString>
pub async fn decode64_async(&self, data: impl AsRef<[u8]>) -> Result<OcString>
Self::decode64 without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn decode_nbt(&self, data: impl AsRef<[u8]>) -> Result<Value>
pub fn decode_nbt(&self, data: impl AsRef<[u8]>) -> Result<Value>
Decode gzipped binary NBT data.
Lua: data.decodeNBT(data:string):table
Direct call (runs immediately, drawing on the per-tick budget; OC’s limit 32).
Sourcepub async fn decode_nbt_async(&self, data: impl AsRef<[u8]>) -> Result<Value>
pub async fn decode_nbt_async(&self, data: impl AsRef<[u8]>) -> Result<Value>
Self::decode_nbt without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn decrypt(
&self,
data: impl AsRef<[u8]>,
key: impl AsRef<[u8]>,
iv: impl AsRef<[u8]>,
) -> Result<OcString>
pub fn decrypt( &self, data: impl AsRef<[u8]>, key: impl AsRef<[u8]>, iv: impl AsRef<[u8]>, ) -> Result<OcString>
Decrypt data with AES.
Lua: data.decrypt(data:string, key:string, iv:string):string
Direct call (runs immediately, drawing on the per-tick budget; OC’s limit 8).
Sourcepub async fn decrypt_async(
&self,
data: impl AsRef<[u8]>,
key: impl AsRef<[u8]>,
iv: impl AsRef<[u8]>,
) -> Result<OcString>
pub async fn decrypt_async( &self, data: impl AsRef<[u8]>, key: impl AsRef<[u8]>, iv: impl AsRef<[u8]>, ) -> Result<OcString>
Self::decrypt without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn deflate(&self, data: impl AsRef<[u8]>) -> Result<OcString>
pub fn deflate(&self, data: impl AsRef<[u8]>) -> Result<OcString>
Applies deflate compression to the data.
Lua: data.deflate(data:string):string
Direct call (runs immediately, drawing on the per-tick budget; OC’s limit 4).
Sourcepub async fn deflate_async(&self, data: impl AsRef<[u8]>) -> Result<OcString>
pub async fn deflate_async(&self, data: impl AsRef<[u8]>) -> Result<OcString>
Self::deflate without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn deserialize_key(
&self,
data: impl AsRef<[u8]>,
type: impl AsRef<[u8]>,
) -> Result<Handle>
pub fn deserialize_key( &self, data: impl AsRef<[u8]>, type: impl AsRef<[u8]>, ) -> Result<Handle>
Restores key from its string representation.
Lua: data.deserializeKey(data:string, type:string):userdata
Direct call (runs immediately, drawing on the per-tick budget; OC’s limit 8).
Sourcepub async fn deserialize_key_async(
&self,
data: impl AsRef<[u8]>,
type: impl AsRef<[u8]>,
) -> Result<Handle>
pub async fn deserialize_key_async( &self, data: impl AsRef<[u8]>, type: impl AsRef<[u8]>, ) -> Result<Handle>
Self::deserialize_key without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn ecdh(&self, priv: Handle, pub: Handle) -> Result<OcString>
pub fn ecdh(&self, priv: Handle, pub: Handle) -> Result<OcString>
Generates a shared key. ecdh(a.priv, b.pub) == ecdh(b.priv, a.pub)
Lua: data.ecdh(priv:userdata, pub:userdata):string
Direct call (runs immediately, drawing on the per-tick budget; OC’s limit 1).
Sourcepub async fn ecdh_async(&self, priv: Handle, pub: Handle) -> Result<OcString>
pub async fn ecdh_async(&self, priv: Handle, pub: Handle) -> Result<OcString>
Self::ecdh without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn ecdsa(
&self,
data: impl AsRef<[u8]>,
key: Handle,
sig: Option<&str>,
) -> Result<Value>
pub fn ecdsa( &self, data: impl AsRef<[u8]>, key: Handle, sig: Option<&str>, ) -> Result<Value>
Signs or verifies data.
Lua: data.ecdsa(data:string, key:userdata[, sig:string]):string or boolean
Direct call (runs immediately, drawing on the per-tick budget; OC’s limit 1).
Sourcepub async fn ecdsa_async(
&self,
data: impl AsRef<[u8]>,
key: Handle,
sig: Option<&str>,
) -> Result<Value>
pub async fn ecdsa_async( &self, data: impl AsRef<[u8]>, key: Handle, sig: Option<&str>, ) -> Result<Value>
Self::ecdsa without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn encode64(&self, data: impl AsRef<[u8]>) -> Result<OcString>
pub fn encode64(&self, data: impl AsRef<[u8]>) -> Result<OcString>
Applies base64 encoding to the data.
Lua: data.encode64(data:string):string
Direct call (runs immediately, drawing on the per-tick budget; OC’s limit 32).
Sourcepub async fn encode64_async(&self, data: impl AsRef<[u8]>) -> Result<OcString>
pub async fn encode64_async(&self, data: impl AsRef<[u8]>) -> Result<OcString>
Self::encode64 without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn encrypt(
&self,
data: impl AsRef<[u8]>,
key: impl AsRef<[u8]>,
iv: impl AsRef<[u8]>,
) -> Result<OcString>
pub fn encrypt( &self, data: impl AsRef<[u8]>, key: impl AsRef<[u8]>, iv: impl AsRef<[u8]>, ) -> Result<OcString>
Encrypt data with AES. Result is binary data.
Lua: data.encrypt(data:string, key:string, iv:string):string
Direct call (runs immediately, drawing on the per-tick budget; OC’s limit 8).
Sourcepub async fn encrypt_async(
&self,
data: impl AsRef<[u8]>,
key: impl AsRef<[u8]>,
iv: impl AsRef<[u8]>,
) -> Result<OcString>
pub async fn encrypt_async( &self, data: impl AsRef<[u8]>, key: impl AsRef<[u8]>, iv: impl AsRef<[u8]>, ) -> Result<OcString>
Self::encrypt without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn generate_key_pair(
&self,
bit_len: Option<Number>,
) -> Result<(Handle, Handle)>
pub fn generate_key_pair( &self, bit_len: Option<Number>, ) -> Result<(Handle, Handle)>
Generates key pair. Returns: public, private keys. Allowed key lengths: 256, 384 bits.
Lua: data.generateKeyPair([bitLen:number]):userdata, userdata
Direct call (runs immediately, drawing on the per-tick budget; OC’s limit 1).
Sourcepub async fn generate_key_pair_async(
&self,
bit_len: Option<Number>,
) -> Result<(Handle, Handle)>
pub async fn generate_key_pair_async( &self, bit_len: Option<Number>, ) -> Result<(Handle, Handle)>
Self::generate_key_pair without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn get_limit(&self) -> Result<Number>
pub fn get_limit(&self) -> Result<Number>
The maximum size of data that can be passed to other functions of the card.
Lua: data.getLimit():number
Direct call (runs immediately, drawing on the per-tick budget).
Sourcepub async fn get_limit_async(&self) -> Result<Number>
pub async fn get_limit_async(&self) -> Result<Number>
Self::get_limit without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn inflate(&self, data: impl AsRef<[u8]>) -> Result<OcString>
pub fn inflate(&self, data: impl AsRef<[u8]>) -> Result<OcString>
Applies inflate decompression to the data.
Lua: data.inflate(data:string):string
Direct call (runs immediately, drawing on the per-tick budget; OC’s limit 4).
Sourcepub async fn inflate_async(&self, data: impl AsRef<[u8]>) -> Result<OcString>
pub async fn inflate_async(&self, data: impl AsRef<[u8]>) -> Result<OcString>
Self::inflate without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn md5(&self, data: impl AsRef<[u8]>) -> Result<OcString>
pub fn md5(&self, data: impl AsRef<[u8]>) -> Result<OcString>
Computes MD5 hash of the data. Result is binary data.
Lua: data.md5(data:string):string
Direct call (runs immediately, drawing on the per-tick budget; OC’s limit 8).
Sourcepub async fn md5_async(&self, data: impl AsRef<[u8]>) -> Result<OcString>
pub async fn md5_async(&self, data: impl AsRef<[u8]>) -> Result<OcString>
Self::md5 without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn random(&self, len: impl Into<Number>) -> Result<OcString>
pub fn random(&self, len: impl Into<Number>) -> Result<OcString>
Generates secure random binary data.
Lua: data.random(len:number):string
Direct call (runs immediately, drawing on the per-tick budget; OC’s limit 4).
Sourcepub async fn random_async(&self, len: impl Into<Number>) -> Result<OcString>
pub async fn random_async(&self, len: impl Into<Number>) -> Result<OcString>
Self::random without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn sha256(&self, data: impl AsRef<[u8]>) -> Result<OcString>
pub fn sha256(&self, data: impl AsRef<[u8]>) -> Result<OcString>
Computes SHA2-256 hash of the data. Result is binary data.
Lua: data.sha256(data:string):string
Direct call (runs immediately, drawing on the per-tick budget; OC’s limit 4).
Sourcepub async fn sha256_async(&self, data: impl AsRef<[u8]>) -> Result<OcString>
pub async fn sha256_async(&self, data: impl AsRef<[u8]>) -> Result<OcString>
Self::sha256 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 Data
impl Component for Data
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.