Skip to main content

OwnerReader

Trait OwnerReader 

Source
pub trait OwnerReader {
    // Required method
    fn owner(&self, at: Pos) -> Option<ShapeId>;
}
Expand description

What a caller reads an owner through: one position, answered from the record behind it.

Who wrote a cell is a question of its own, asked by a front end deciding what a click landed on and by nothing that renders, so it rides on an interface separate from CellReader. Buffer answers both.

Required Methods§

Source

fn owner(&self, at: Pos) -> Option<ShapeId>

The identity of whoever decided the cell at the position at, or None when nobody holds that position.

The answer is a value rather than a borrow of one. An identity is two bytes and Copy, so a caller holds what it is given and may go on drawing into the buffer and ask again, which is what a front end deciding what to do with a cell it was handed has to be able to do. Nothing is owed by holding it and nothing is spent by copying it.

None covers two cases and distinguishes neither, in the type or in the answer: a position no shape wrote, and a position a shape wrote without deciding. Nothing was ever recorded at either, so there is nothing to say which it was. A position outside the window is the first of them: the record never holds one.

The position is one a caller already holds, and reaching it from a click is Window::position’s job rather than this method’s: an offset counted from the window’s corner is the one position that offset reaches, and a caller that added the origin itself would be asking about another cell.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§