Struct Locked

Source
pub struct Locked<'a, B: Buffer> { /* private fields */ }
Expand description

A GPU component on which methods can be invoked.

This type combines a GPU 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 Gpu::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 'a lifetime is the lifetime of the invoker and the buffer. The B type is the type of scratch buffer to use.

Implementations§

Source§

impl<'a, B: Buffer> Locked<'a, B>

Source

pub async fn bind(&mut self, screen: Address, reset: bool) -> Result<(), Error>

Binds the GPU to a screen.

If reset is true, then the screen is reset to its maximum resolution and colour depth, and its colours are set to white on black. The text content, however, is not cleared.

§Errors
Source

pub async fn get_screen(&mut self) -> Result<Option<Address>, Error>

Returns the address of the screen the GPU is bound to, or None if it is unbound.

§Errors
Source

pub async fn get_background(&mut self) -> Result<Colour, Error>

Returns the background colour.

§Errors
Source

pub async fn set_background( &mut self, colour: Colour, ) -> Result<(Rgb, Option<PaletteIndex>), Error>

Sets the background colour, returning the old colour.

§Errors
Source

pub async fn get_foreground(&mut self) -> Result<Colour, Error>

Returns the foreground colour.

§Errors
Source

pub async fn set_foreground( &mut self, colour: Colour, ) -> Result<(Rgb, Option<PaletteIndex>), Error>

Sets the foreground colour, returning the old colour.

§Errors
Source

pub async fn get_palette_colour( &mut self, index: PaletteIndex, ) -> Result<Rgb, Error>

Returns the colour at a palette index.

§Errors
Source

pub async fn set_palette_colour( &mut self, index: PaletteIndex, colour: Rgb, ) -> Result<Rgb, Error>

Sets the colour at a palette index, returning the old colour.

§Errors
Source

pub async fn max_depth(&mut self) -> Result<u8, Error>

Returns the maximum supported colour depth based on the tiers of the GPU and the bound screen.

§Errors
Source

pub async fn get_depth(&mut self) -> Result<u8, Error>

Returns the colour depth currently in use.

§Errors
Source

pub async fn set_depth(&mut self, depth: u8) -> Result<(), Error>

Sets the colour depth.

§Errors
Source

pub async fn max_resolution(&mut self) -> Result<Dimension, Error>

Returns the maximum supported resolution based on the tiers of the GPU and the bound screen.

§Errors
Source

pub async fn get_resolution(&mut self) -> Result<Dimension, Error>

Returns the resolution currently in use.

§Errors
Source

pub async fn set_resolution( &mut self, resolution: Dimension, ) -> Result<bool, Error>

Sets the screen resolution, returning whether or not it was changed from its previous value.

§Errors
Source

pub async fn get_viewport(&mut self) -> Result<Dimension, Error>

Returns the viewport currently in use.

§Errors
Source

pub async fn set_viewport( &mut self, resolution: Dimension, ) -> Result<bool, Error>

Sets the viewport, returning whether or not it was changed from its previous value.

§Errors
Source

pub async fn get( &mut self, point: Point, ) -> Result<CharacterCellContents, Error>

Returns the character and colours at a specific character cell.

It is possible for a Java string to contain an unpaired UTF-16 surrogate half. It is possible (in Lua, at least) to place such a byte sequence into a character cell in a screen. Should this method be called on such a character cell, a replacement character is silently returned instead.

§Errors
Source

pub async fn set( &mut self, position: Point, text: &str, direction: TextDirection, ) -> Result<(), Error>

Writes text to the screen.

§Errors
Source

pub async fn copy( &mut self, source: Point, dimension: Dimension, translation: Vector2, ) -> Result<(), Error>

Copies data from one rectangle to another.

§Errors
Source

pub async fn fill( &mut self, target: Point, dimension: Dimension, character: char, ) -> Result<(), Error>

Fills a rectangle with a character.

§Errors

Trait Implementations§

Source§

impl<B: Buffer> Debug for Locked<'_, B>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, B> Freeze for Locked<'a, B>

§

impl<'a, B> RefUnwindSafe for Locked<'a, B>
where B: RefUnwindSafe,

§

impl<'a, B> Send for Locked<'a, B>
where B: Send,

§

impl<'a, B> Sync for Locked<'a, B>
where B: Sync,

§

impl<'a, B> Unpin for Locked<'a, B>

§

impl<'a, B> !UnwindSafe for Locked<'a, B>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.