Enum pdbtbx::Context[][src]

pub enum Context {
    None,
    Show {
        line: String,
    },
    FullLine {
        linenumber: usize,
        line: String,
    },
    Line {
        linenumber: usize,
        line: String,
        offset: usize,
        length: usize,
    },
    Range {
        start_linenumber: usize,
        lines: Vec<String>,
        offset: usize,
    },
}

A struct to define the context of an error message

Variants

None

When no context can be given

Show

When only a line (eg filename) can be shown

Fields of Show

line: String

The line to be shown to the user (eg filename)

FullLine

When a full line is faulty and no special position can be annotated

Fields of FullLine

linenumber: usize

The line number to recognise where the error is located

line: String

The line to show the issue itself

Line

When a special position can be annotated on a line.

     |
104  | ATOM      O  N   MET A   1      27.251  24.447   2.594  1.00 11.79           N
     |        ^^^^
       <-   -><-->

The first space (annotated by <-, ->) is the offset, in this case 7. The second space is the length, in this case 4.

Fields of Line

linenumber: usize

The line number to recognise where the error is located.

line: String

The line to show the issue itself.

offset: usize

The offset of the special position to be annotated.

length: usize

The length of the special position to be annotated.

Range

To show multiple lines where an error occurred.

Fields of Range

start_linenumber: usize

The linenumber of the first line

lines: Vec<String>

The lines to show

offset: usize

The possible offset of the first line, will be padded with spaces

Implementations

impl Context[src]

pub fn none() -> Context[src]

Creates a new context when no context can be given

pub fn show(line: &str) -> Context[src]

Creates a new context when only a line (eg filename) can be shown

pub fn full_line(linenumber: usize, line: &str) -> Context[src]

Creates a new context when a full line is faulty and no special position can be annotated

pub fn line(
    linenumber: usize,
    line: &str,
    offset: usize,
    length: usize
) -> Context
[src]

Creates a new context when a special position can be annotated on a line

pub fn position(pos: &Position<'_>) -> Context[src]

Creates a new context to highlight a certain position

pub fn range(start: &Position<'_>, end: &Position<'_>) -> Context[src]

Creates a new context from a start and end point within a single file

Trait Implementations

impl Clone for Context[src]

impl Debug for Context[src]

impl Display for Context[src]

impl Eq for Context[src]

impl PartialEq<Context> for Context[src]

impl StructuralEq for Context[src]

impl StructuralPartialEq for Context[src]

Auto Trait Implementations

impl RefUnwindSafe for Context

impl Send for Context

impl Sync for Context

impl Unpin for Context

impl UnwindSafe for Context

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.