pub struct Drive(pub Address);Expand description
The drive component (9 methods).
Provided by OpenComputers’ Drive.
Tuple Fields§
§0: AddressImplementations§
Source§impl Drive
impl Drive
Sourcepub fn get_capacity(&self) -> Result<Number>
pub fn get_capacity(&self) -> Result<Number>
Returns the total capacity of the drive, in bytes.
Lua: drive.getCapacity():number
Direct call (runs immediately, drawing on the per-tick budget).
Sourcepub async fn get_capacity_async(&self) -> Result<Number>
pub async fn get_capacity_async(&self) -> Result<Number>
Self::get_capacity without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn get_label(&self) -> Result<OcString>
pub fn get_label(&self) -> Result<OcString>
Get the current label of the drive.
Lua: drive.getLabel():string
Direct call (runs immediately, drawing on the per-tick budget).
Sourcepub async fn get_label_async(&self) -> Result<OcString>
pub async fn get_label_async(&self) -> Result<OcString>
Self::get_label without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn get_platter_count(&self) -> Result<Number>
pub fn get_platter_count(&self) -> Result<Number>
Returns the number of platters in the drive.
Lua: drive.getPlatterCount():number
Direct call (runs immediately, drawing on the per-tick budget).
Sourcepub async fn get_platter_count_async(&self) -> Result<Number>
pub async fn get_platter_count_async(&self) -> Result<Number>
Self::get_platter_count without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn get_sector_size(&self) -> Result<Number>
pub fn get_sector_size(&self) -> Result<Number>
Returns the size of a single sector on the drive, in bytes.
Lua: drive.getSectorSize():number
Direct call (runs immediately, drawing on the per-tick budget).
Sourcepub async fn get_sector_size_async(&self) -> Result<Number>
pub async fn get_sector_size_async(&self) -> Result<Number>
Self::get_sector_size without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn read_byte(&self, offset: impl Into<Number>) -> Result<Number>
pub fn read_byte(&self, offset: impl Into<Number>) -> Result<Number>
Read a single byte at the specified offset.
Lua: drive.readByte(offset:number):number
Direct call (runs immediately, drawing on the per-tick budget).
Sourcepub async fn read_byte_async(&self, offset: impl Into<Number>) -> Result<Number>
pub async fn read_byte_async(&self, offset: impl Into<Number>) -> Result<Number>
Self::read_byte without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn read_sector(&self, sector: impl Into<Number>) -> Result<OcString>
pub fn read_sector(&self, sector: impl Into<Number>) -> Result<OcString>
Read the current contents of the specified sector.
Lua: drive.readSector(sector:number):string
Direct call (runs immediately, drawing on the per-tick budget).
Sourcepub async fn read_sector_async(
&self,
sector: impl Into<Number>,
) -> Result<OcString>
pub async fn read_sector_async( &self, sector: impl Into<Number>, ) -> Result<OcString>
Self::read_sector without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn set_label(&self, value: impl AsRef<[u8]>) -> Result<OcString>
pub fn set_label(&self, value: impl AsRef<[u8]>) -> Result<OcString>
Sets the label of the drive. Returns the new value, which may be truncated.
Lua: drive.setLabel(value:string):string
Indirect call: waits for the next server tick.
Sourcepub async fn set_label_async(&self, value: impl AsRef<[u8]>) -> Result<OcString>
pub async fn set_label_async(&self, value: impl AsRef<[u8]>) -> Result<OcString>
Self::set_label without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn write_byte(
&self,
offset: impl Into<Number>,
value: impl Into<Number>,
) -> Result<()>
pub fn write_byte( &self, offset: impl Into<Number>, value: impl Into<Number>, ) -> Result<()>
Write a single byte to the specified offset.
Lua: drive.writeByte(offset:number, value:number)
Direct call (runs immediately, drawing on the per-tick budget).
Sourcepub async fn write_byte_async(
&self,
offset: impl Into<Number>,
value: impl Into<Number>,
) -> Result<()>
pub async fn write_byte_async( &self, offset: impl Into<Number>, value: impl Into<Number>, ) -> Result<()>
Self::write_byte without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn write_sector(
&self,
sector: impl Into<Number>,
value: impl AsRef<[u8]>,
) -> Result<()>
pub fn write_sector( &self, sector: impl Into<Number>, value: impl AsRef<[u8]>, ) -> Result<()>
Write the specified contents to the specified sector.
Lua: drive.writeSector(sector:number, value:string)
Direct call (runs immediately, drawing on the per-tick budget).
Sourcepub async fn write_sector_async(
&self,
sector: impl Into<Number>,
value: impl AsRef<[u8]>,
) -> Result<()>
pub async fn write_sector_async( &self, sector: impl Into<Number>, value: impl AsRef<[u8]>, ) -> Result<()>
Self::write_sector 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 Drive
impl Component for Drive
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.