[−][src]Trait tweep::Positional
This trait represents something that has one or more Position
s 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 Position
s 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,
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,
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,
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,
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,
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
Implementations on Foreign Types
impl<T, E> Positional for Result<T, E> where
T: Positional,
E: Positional,
[src]
T: Positional,
E: Positional,
fn get_position(&self) -> &Position
[src]
fn mut_position(&mut self) -> &mut Position
[src]
fn get_column(&self) -> Option<usize>
[src]
fn set_column(&mut self, col: usize)
[src]
fn offset_column(&mut self, offset: usize)
[src]
fn get_row(&self) -> Option<usize>
[src]
fn set_row(&mut self, row: usize)
[src]
fn offset_row(&mut self, offset: usize)
[src]
fn get_file(&self) -> Option<&str>
[src]
fn set_file(&mut self, file: String)
[src]
Implementors
impl Positional for PassageContent
[src]
fn get_position(&self) -> &Position
[src]
fn mut_position(&mut self) -> &mut Position
[src]
impl Positional for Error
[src]
fn get_position(&self) -> &Position
[src]
fn mut_position(&mut self) -> &mut Position
[src]
impl Positional for ErrorList
[src]
fn set_row(&mut self, row: usize)
[src]
fn set_column(&mut self, col: usize)
[src]
fn set_file(&mut self, file: String)
[src]
fn offset_column(&mut self, offset: usize)
[src]
fn offset_row(&mut self, offset: usize)
[src]
impl Positional for Passage
[src]
fn set_row(&mut self, row: usize)
[src]
fn set_column(&mut self, col: usize)
[src]
fn offset_column(&mut self, offset: usize)
[src]
fn offset_row(&mut self, offset: usize)
[src]
fn set_file(&mut self, file: String)
[src]
impl Positional for PassageHeader
[src]
fn get_position(&self) -> &Position
[src]
fn mut_position(&mut self) -> &mut Position
[src]
impl Positional for ScriptContent
[src]
fn get_position(&self) -> &Position
[src]
fn mut_position(&mut self) -> &mut Position
[src]
impl Positional for StoryData
[src]
fn get_position(&self) -> &Position
[src]
fn mut_position(&mut self) -> &mut Position
[src]
impl Positional for StoryPassages
[src]
impl Positional for StoryTitle
[src]
fn get_position(&self) -> &Position
[src]
fn mut_position(&mut self) -> &mut Position
[src]
impl Positional for StylesheetContent
[src]
fn get_position(&self) -> &Position
[src]
fn mut_position(&mut self) -> &mut Position
[src]
impl Positional for TwineContent
[src]
fn get_position(&self) -> &Position
[src]
fn mut_position(&mut self) -> &mut Position
[src]
impl Positional for TwineLink
[src]
fn get_position(&self) -> &Position
[src]
fn mut_position(&mut self) -> &mut Position
[src]
impl Positional for Warning
[src]
fn get_position(&self) -> &Position
[src]
fn mut_position(&mut self) -> &mut Position
[src]
impl<T> Positional for Output<T> where
T: Positional,
[src]
T: Positional,