[][src]Trait tweep::Positional

pub trait Positional {
    fn get_position(&self) -> &Position { ... }
fn mut_position(&mut self) -> &mut Position { ... }
fn get_column(&self) -> Option<usize> { ... }
fn set_column(&mut self, col: usize) { ... }
fn offset_column(&mut self, offset: usize) { ... }
fn get_row(&self) -> Option<usize> { ... }
fn set_row(&mut self, row: usize) { ... }
fn offset_row(&mut self, offset: usize) { ... }
fn get_file(&self) -> Option<&str> { ... }
fn set_file(&mut self, file: String) { ... }
fn with_offset_row(self, offset: usize) -> Self
    where
        Self: Sized
, { ... }
fn with_offset_column(self, offset: usize) -> Self
    where
        Self: Sized
, { ... }
fn with_column(self, col: usize) -> Self
    where
        Self: Sized
, { ... }
fn with_row(self, row: usize) -> Self
    where
        Self: Sized
, { ... }
fn with_file(self, file: String) -> Self
    where
        Self: Sized
, { ... } }

This trait represents something that has one or more Positions associated with it, which can be manipulated through the interface provided.

There exists two major use cases for this trait:

Basic usage

If the implementor of the trait has a single Position that can be directly manipulated through the interface, it only needs to provide implementations for the get_position and mut_position methods. All additional functionality will be provided by the default trait implementations.

Advanced usage

If the implementor of the trait has more complex positional data to track (multiple Positions for instance), the situation becomes more complex. Any applicable set_* and offset_* methods should be implemented directly and the get_position and mut_position methods will default to unimplemented. The with_* functionality will be automatically available as long as the associated set_* functionality is provided, but any other functionality will not be available.

Result

An implementation of Positional is provided for any Result<T, E> where T and E themselves both implement Positional which will forward any Positional calls to the Ok or Err variant contained within the Result.

Provided methods

fn get_position(&self) -> &Position

Get an immutable reference to the associated Position. Unimplemented by default.

fn mut_position(&mut self) -> &mut Position

Get an mutable reference to the associated Position. Unimplemented by default.

fn get_column(&self) -> Option<usize>

Gets the column of the associated Position if it has one

Uses get_position by default

fn set_column(&mut self, col: usize)

Sets the column of the associated Position

Uses mut_position by default

fn offset_column(&mut self, offset: usize)

Offsets the column of the associated Position by offset

Uses mut_position by default

fn get_row(&self) -> Option<usize>

Gets the row of the associated Position if it has one

Uses get_position by default

fn set_row(&mut self, row: usize)

Sets the row of the associated Position

Uses mut_position by default

fn offset_row(&mut self, offset: usize)

Offsets the row of the associated Position by offset

Uses mut_position by default

fn get_file(&self) -> Option<&str>

Gets the file name of the associated Position if it has one

Uses get_position by default

fn set_file(&mut self, file: String)

Sets the file name of the associated Position

Uses mut_position by default

fn with_offset_row(self, offset: usize) -> Self where
    Self: Sized

Moves self, calls offset_row with the given offset and returns a new instance with the offset value

Uses offset_row by default

fn with_offset_column(self, offset: usize) -> Self where
    Self: Sized

Moves self, calls offset_column with the given offset and returns a new instance with the offset value

Uses offset_column by default

fn with_column(self, col: usize) -> Self where
    Self: Sized

Moves self, calls set_column with the given col value and returns a new instance with the set value

Uses set_column by default

fn with_row(self, row: usize) -> Self where
    Self: Sized

Moves self, calls set_row with the given row value and returns a new instance with the set value

Uses set_row by default

fn with_file(self, file: String) -> Self where
    Self: Sized

Moves self, calls set_file with the given file value and returns a new instance with the set value

Uses set_file by default

Loading content...

Implementations on Foreign Types

impl<T, E> Positional for Result<T, E> where
    T: Positional,
    E: Positional
[src]

Loading content...

Implementors

impl Positional for PassageContent[src]

impl Positional for Error[src]

impl Positional for ErrorList[src]

impl Positional for Passage[src]

impl Positional for PassageHeader[src]

impl Positional for ScriptContent[src]

impl Positional for StoryData[src]

impl Positional for StoryPassages[src]

impl Positional for StoryTitle[src]

impl Positional for StylesheetContent[src]

impl Positional for TwineContent[src]

impl Positional for TwineLink[src]

impl Positional for Warning[src]

impl<T> Positional for Output<T> where
    T: Positional
[src]

Loading content...