pub struct Database(pub Address);Expand description
The database component (7 methods).
Provided by OpenComputers’ UpgradeDatabase.
Tuple Fields§
§0: AddressImplementations§
Source§impl Database
impl Database
Sourcepub fn clear(&self, slot: impl Into<Number>) -> Result<bool>
pub fn clear(&self, slot: impl Into<Number>) -> Result<bool>
Clears the specified slot. Returns true if there was something in the slot before.
Lua: database.clear(slot:number):boolean
Indirect call: waits for the next server tick.
Sourcepub async fn clear_async(&self, slot: impl Into<Number>) -> Result<bool>
pub async fn clear_async(&self, slot: impl Into<Number>) -> Result<bool>
Self::clear without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn clone(&self, address: impl AsRef<[u8]>) -> Result<Number>
pub fn clone(&self, address: impl AsRef<[u8]>) -> Result<Number>
Copies the data stored in this database to another database with the specified address.
Lua: database.clone(address:string):number
Indirect call: waits for the next server tick.
Sourcepub async fn clone_async(&self, address: impl AsRef<[u8]>) -> Result<Number>
pub async fn clone_async(&self, address: impl AsRef<[u8]>) -> Result<Number>
Self::clone without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn compute_hash(&self, slot: impl Into<Number>) -> Result<OcString>
pub fn compute_hash(&self, slot: impl Into<Number>) -> Result<OcString>
Computes a hash value for the item stack in the specified slot.
Lua: database.computeHash(slot:number):string
Indirect call: waits for the next server tick.
Sourcepub async fn compute_hash_async(
&self,
slot: impl Into<Number>,
) -> Result<OcString>
pub async fn compute_hash_async( &self, slot: impl Into<Number>, ) -> Result<OcString>
Self::compute_hash without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn copy(
&self,
from_slot: impl Into<Number>,
to_slot: impl Into<Number>,
address: Option<&str>,
) -> Result<bool>
pub fn copy( &self, from_slot: impl Into<Number>, to_slot: impl Into<Number>, address: Option<&str>, ) -> Result<bool>
Copies an entry to another slot, optionally to another database. Returns true if something was overwritten.
Lua: database.copy(fromSlot:number, toSlot:number[, address:string]):boolean
Indirect call: waits for the next server tick.
Sourcepub async fn copy_async(
&self,
from_slot: impl Into<Number>,
to_slot: impl Into<Number>,
address: Option<&str>,
) -> Result<bool>
pub async fn copy_async( &self, from_slot: impl Into<Number>, to_slot: impl Into<Number>, address: Option<&str>, ) -> Result<bool>
Self::copy without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn get(&self, slot: impl Into<Number>) -> Result<Value>
pub fn get(&self, slot: impl Into<Number>) -> Result<Value>
Get the representation of the item stack stored in the specified slot.
Lua: database.get(slot:number):table
Indirect call: waits for the next server tick.
Sourcepub async fn get_async(&self, slot: impl Into<Number>) -> Result<Value>
pub async fn get_async(&self, slot: impl Into<Number>) -> Result<Value>
Self::get without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn index_of(&self, hash: impl AsRef<[u8]>) -> Result<Number>
pub fn index_of(&self, hash: impl AsRef<[u8]>) -> Result<Number>
Get the index of an item stack with the specified hash. Returns a negative value if no such stack was found.
Lua: database.indexOf(hash:string):number
Indirect call: waits for the next server tick.
Sourcepub async fn index_of_async(&self, hash: impl AsRef<[u8]>) -> Result<Number>
pub async fn index_of_async(&self, hash: impl AsRef<[u8]>) -> Result<Number>
Self::index_of without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn set(
&self,
slot: impl Into<Number>,
id: impl AsRef<[u8]>,
damage: impl Into<Number>,
nbt: impl AsRef<[u8]>,
) -> Result<bool>
pub fn set( &self, slot: impl Into<Number>, id: impl AsRef<[u8]>, damage: impl Into<Number>, nbt: impl AsRef<[u8]>, ) -> Result<bool>
Sets an item into the specified database slot. The NBT tag is expected in string (SNBT) format.
Lua: database.set(slot:number, id:string, damage:number, nbt:string):boolean
Indirect call: waits for the next server tick.
Trait Implementations§
Source§impl Component for Database
impl Component for Database
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.