Skip to main content

Data

Struct Data 

Source
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: Address

Implementations§

Source§

impl Data

Source

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).

Source

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.

Source

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).

Source

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.

Source

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).

Source

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.

Source

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).

Source

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.

Source

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).

Source

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.

Source

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).

Source

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.

Source

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).

Source

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.

Source

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).

Source

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.

Source

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).

Source

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.

Source

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).

Source

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.

Source

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).

Source

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.

Source

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).

Source

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.

Source

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).

Source

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.

Source

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).

Source

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.

Source

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).

Source

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.

Source

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).

Source

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 Clone for Data

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 Data

Source§

const KIND: &'static str = "data"

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 Data

Source§

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

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

impl Eq for Data

Source§

impl Hash for Data

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 Data

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 Data

Auto Trait Implementations§

§

impl Forget for Data

§

impl Freeze for Data

§

impl Move for Data

§

impl RefUnwindSafe for Data

§

impl Send for Data

§

impl Sync for Data

§

impl Unpin for Data

§

impl UnsafeUnpin for Data

§

impl UnwindSafe for Data

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.