pub struct Locked<'invoker, 'buffer, B: Buffer> { /* private fields */ }
Expand description
A redstone component on which methods can be invoked.
This type combines a redstone block or card address, an Invoker
that can be used to make
method calls, and a scratch buffer used to perform CBOR encoding and decoding. A value of this
type can be created by calling Redstone::lock
, and it can be dropped to return the borrow
of the invoker and buffer to the caller so they can be reused for other purposes.
The 'invoker
lifetime is the lifetime of the invoker. The 'buffer
lifetime is the lifetime
of the buffer. The B
type is the type of scratch buffer to use.
Implementations§
Source§impl<'invoker, 'buffer, B: Buffer> Locked<'invoker, 'buffer, B>
impl<'invoker, 'buffer, B: Buffer> Locked<'invoker, 'buffer, B>
Sourcepub async fn get_input(&mut self) -> Result<[u8; 6], Error>
pub async fn get_input(&mut self) -> Result<[u8; 6], Error>
Returns the signal strengths received on all six sides.
The returned array is indexed by side. For a redstone block, the indices should be absolute sides. For a redstone card in a computer, the indices should be relative sides.
§Errors
Sourcepub async fn get_side_input(&mut self, side: impl Side) -> Result<u8, Error>
pub async fn get_side_input(&mut self, side: impl Side) -> Result<u8, Error>
Returns the signal strengths received on a side.
For a redstone block, the side
parameter must be an absolute
side. For a redstone card in a computer, the side
parameter
must be a relative side.
§Errors
Sourcepub async fn get_bundled_input(&mut self) -> Result<[[u8; 16]; 6], Error>
pub async fn get_bundled_input(&mut self) -> Result<[[u8; 16]; 6], Error>
Returns the bundled signal strengths received on all six sides.
The returned array is indexed by side. For a redstone block, the indices should be absolute sides. For a redstone card in a computer, the indices should be relative sides. Each element of the outer array is itself an array indexed by colour.
§Errors
Sourcepub async fn get_side_bundled_input(
&mut self,
side: impl Side,
) -> Result<[u8; 16], Error>
pub async fn get_side_bundled_input( &mut self, side: impl Side, ) -> Result<[u8; 16], Error>
Returns the bundled signal strengths received on a side.
For a redstone block, the side
parameter must be an absolute
side. For a redstone card in a computer, the side
parameter
must be a relative side.
The returned array is indexed by colour.
§Errors
Sourcepub async fn get_side_colour_bundled_input(
&mut self,
side: impl Side,
colour: Colour,
) -> Result<u8, Error>
pub async fn get_side_colour_bundled_input( &mut self, side: impl Side, colour: Colour, ) -> Result<u8, Error>
Returns the bundled signal strength received on a side on a single colour of wire.
For a redstone block, the side
parameter must be an absolute
side. For a redstone card in a computer, the side
parameter
must be a relative side.
§Errors
Sourcepub async fn get_output(&mut self) -> Result<[u8; 6], Error>
pub async fn get_output(&mut self) -> Result<[u8; 6], Error>
Returns the signal strengths emitted on all six sides.
The returned array is indexed by side. For a redstone block, the indices should be absolute sides. For a redstone card in a computer, the indices should be relative sides.
§Errors
Sourcepub async fn get_side_output(&mut self, side: impl Side) -> Result<u8, Error>
pub async fn get_side_output(&mut self, side: impl Side) -> Result<u8, Error>
Returns the signal strength emitted on a side.
For a redstone block, the side
parameter must be an absolute
side. For a redstone card in a computer, the side
parameter
must be a relative side.
§Errors
Sourcepub async fn get_bundled_output(&mut self) -> Result<[[u8; 16]; 6], Error>
pub async fn get_bundled_output(&mut self) -> Result<[[u8; 16]; 6], Error>
Returns the bundled signal strengths emitted on all six sides.
The returned array is indexed by side. For a redstone block, the indices should be absolute sides. For a redstone card in a computer, the indices should be relative sides. Each element of the outer array is itself an array indexed by colour.
§Errors
Sourcepub async fn get_side_bundled_output(
&mut self,
side: impl Side,
) -> Result<[u8; 16], Error>
pub async fn get_side_bundled_output( &mut self, side: impl Side, ) -> Result<[u8; 16], Error>
Returns the bundled signal strengths emitted on a side.
For a redstone block, the side
parameter must be an absolute
side. For a redstone card in a computer, the side
parameter
must be a relative side.
The returned array is indexed by colour.
§Errors
Sourcepub async fn get_side_colour_bundled_output(
&mut self,
side: impl Side,
colour: Colour,
) -> Result<u8, Error>
pub async fn get_side_colour_bundled_output( &mut self, side: impl Side, colour: Colour, ) -> Result<u8, Error>
Returns the bundled signal strength emitted on a side on a single colour of wire.
For a redstone block, the side
parameter must be an absolute
side. For a redstone card in a computer, the side
parameter
must be a relative side.
§Errors
Sourcepub async fn set_output(
&mut self,
levels: &[Option<u8>; 6],
) -> Result<[u8; 6], Error>
pub async fn set_output( &mut self, levels: &[Option<u8>; 6], ) -> Result<[u8; 6], Error>
Sets the signal strengths to emit on any subset of the sides.
The levels
parameter contains an element for each side. For a redstone block, the indices
into this array are absolute sides. For a redstone card in a
computer, the indices are relative sides. Each element of
the array can be Some
with the new signal strength to emit, or None
to leave that side
unmodified.
The old signal levels, prior to modification, are returned.
§Errors
Sourcepub async fn set_side_output(
&mut self,
side: impl Side,
level: u8,
) -> Result<u8, Error>
pub async fn set_side_output( &mut self, side: impl Side, level: u8, ) -> Result<u8, Error>
Sets the signal strength to emit on a single side.
The side
parameter selects the side to modify. For a redstone block, the value must be an
absolute side. For a redstone card in a computer, the value
must be a relative side.
The old signal level, prior to modification, is returned.
§Errors
Sourcepub async fn set_bundled_output(
&mut self,
levels: &[[Option<u8>; 16]; 6],
) -> Result<(), Error>
pub async fn set_bundled_output( &mut self, levels: &[[Option<u8>; 16]; 6], ) -> Result<(), Error>
Sets the bundled signal strengths to emit on any subset of wires on any subset of sides.
The levels
parameter contains an element for each side. For a redstone block, the indices
into this array are absolute sides. For a redstone card in a
computer, the indices are relative sides. Each element of
the array is itself another array. The inner arrays are indexed by colour. Each element of
the inner array can be Some
with the new signal strength to emit, or None
to leave that
colour unmodified.
§Errors
Sourcepub async fn set_side_bundled_output(
&mut self,
side: impl Side,
levels: &[Option<u8>; 16],
) -> Result<(), Error>
pub async fn set_side_bundled_output( &mut self, side: impl Side, levels: &[Option<u8>; 16], ) -> Result<(), Error>
Sets the bundled signal strengths to emit on any subset of wires on a single side.
The side
parameter selects the side to modify. For a redstone block, the value must be an
absolute side. For a redstone card in a computer, the value
must be a relative side.
The levels
parameter contains an element for each colour. Each element of levels
can be
Some
with the new signal strength to emit, or None
to leave that colour unmodified.
§Errors
Sourcepub async fn set_side_colour_bundled_output(
&mut self,
side: impl Side,
colour: Colour,
level: u8,
) -> Result<u8, Error>
pub async fn set_side_colour_bundled_output( &mut self, side: impl Side, colour: Colour, level: u8, ) -> Result<u8, Error>
Sets the bundled signal strength to emit on a single wire on a single side.
The side
parameter selects the side to modify. For a redstone block, the value must be an
absolute side. For a redstone card in a computer, the value
must be a relative side.
The old signal level, prior to modification, is returned.
§Errors
Sourcepub async fn get_comparator_input(
&mut self,
side: impl Side,
) -> Result<u8, Error>
pub async fn get_comparator_input( &mut self, side: impl Side, ) -> Result<u8, Error>
Returns the comparator value on a given side.
For a redstone block, the side
parameter must be an absolute
side. For a redstone card in a computer, the side
parameter
must be a relative side.
The returned value is the signal level that would be emitted by a comparator sensing the adjacent block. If the target block is not readable by a comparator, zero is returned.
§Errors
Sourcepub async fn get_wake_threshold(&mut self) -> Result<u32, Error>
pub async fn get_wake_threshold(&mut self) -> Result<u32, Error>
Returns the wake threshold.
When any redstone input changes from being strictly less than the threshold to greater than or equal to the threshold, the containing computer (in the case of a redstone card) or all connected computers (in the case of a redstone block) are powered on if they are off.
§Errors
Sourcepub async fn set_wake_threshold(&mut self, threshold: u32) -> Result<u32, Error>
pub async fn set_wake_threshold(&mut self, threshold: u32) -> Result<u32, Error>
Sets the wake threshold.
When any redstone input changes from being strictly less than the threshold to greater than or equal to the threshold, the containing computer (in the case of a redstone card) or all connected computers (in the case of a redstone block) are powered on if they are off.
The old wake threshold, prior to modification, is returned.