Struct glsl_lang::transpiler::glsl::FormattingState

source ·
pub struct FormattingState<'s> {
    pub settings: &'s FormattingSettings,
    indentation_level: u32,
    new_line_pending: bool,
    in_function_definition_statement: bool,
    last_flush_line_flushed_line: bool,
    is_first_external_declaration: bool,
}
Expand description

Formatting state of the GLSL transpiler

Fields§

§settings: &'s FormattingSettings

Formatting settings

§indentation_level: u32§new_line_pending: bool§in_function_definition_statement: bool§last_flush_line_flushed_line: bool§is_first_external_declaration: bool

Implementations§

source§

impl<'s> FormattingState<'s>

source

fn write_indent<F>(&self, f: &mut F) -> Result
where F: Write + ?Sized,

source

fn write_line<F>(&mut self, f: &mut F) -> Result
where F: Write + ?Sized,

source

pub fn new_line(&mut self, required: bool) -> Result

Append a pending new line to the output

source

pub fn consume_newline(&mut self)

Consume the pending newlines

source

pub fn flush_line<F>(&mut self, f: &mut F) -> Result
where F: Write + ?Sized,

Flush pending newlines to the output, if any

source

pub fn move_to_empty_line<F>(&mut self, f: &mut F) -> Result
where F: Write + ?Sized,

Makes sure that the next text to be written to the output will be put at an empty line, or at a line with only indentation characters. Does nothing if the output is already at an empty line

source

pub fn flush_space<F>(&mut self, f: &mut F) -> Result
where F: Write + ?Sized,

Flush pending newlines as spaces to the output, if any

source

pub fn enter_compound_statement_block<F>(&mut self, f: &mut F) -> Result
where F: Write + ?Sized,

Enter a new compound statement block, and update the indentation level

source

pub fn enter_external_declaration<F>(&mut self, f: &mut F) -> Result
where F: Write + ?Sized,

Enters a new external declaration, flushing pending newlines

source

pub fn exit_external_declaration(&mut self)

Exits the current external declaration

source

pub fn enter_block<F>(&mut self, f: &mut F) -> Result
where F: Write + ?Sized,

Enter a new block, and update the indentation level

source

fn enter_block_inner<F>(&mut self, f: &mut F) -> Result
where F: Write + ?Sized,

Common logic for entering a new block, and updating the indentation level

source

pub fn exit_block<F>(&mut self, f: &mut F) -> Result
where F: Write + ?Sized,

Exit the current block, and update the indentation level

source

pub fn enter_function_definition_statement(&mut self)

Enter a new function definition statement

source

pub fn consume_function_definition_statement(&mut self)

Consume the current function definition statement

source

pub fn enter_collapsed_compound_statement(&mut self) -> Result

Enter a collapsed compound statement

source

pub fn exit_collapsed_compound_statement(&mut self) -> Result

Exit the current collapsed compound statement

source

pub fn enter_initializer_list<F>(&mut self, f: &mut F) -> Result
where F: Write + ?Sized,

Enter a list initializer

source

pub fn end_initializer_list<F>(&mut self, f: &mut F) -> Result
where F: Write + ?Sized,

Exit the current list initializer

source

pub fn enter_case_label<F>(&mut self, f: &mut F) -> Result
where F: Write + ?Sized,

Enter a case label

source

pub fn write_else<F>(&mut self, f: &mut F) -> Result
where F: Write + ?Sized,

Write a else keyword, part of an if statement

source

pub fn write_struct_field_separator<F>(&mut self, f: &mut F) -> Result
where F: Write + ?Sized,

Write a struct field separator

source

pub fn write_list_separator<F>(&mut self, f: &mut F) -> Result
where F: Write + ?Sized,

Write a list separator

source

pub fn write_for_statement_separator<F>(&mut self, f: &mut F) -> Result
where F: Write + ?Sized,

Write a for statement separator

source

pub fn write_struct_declaration_terminator<F>(&mut self, f: &mut F) -> Result
where F: Write + ?Sized,

Write a struct declaration terminator

source

pub fn write_declaration_terminator<F>(&mut self, f: &mut F) -> Result
where F: Write + ?Sized,

Write a declaration terminator

source

pub fn write_binary_op<F>(&self, f: &mut F, op: &str) -> Result
where F: Write + ?Sized,

Write a binary operator

source

pub fn write_statement_terminator<F>(&mut self, f: &mut F) -> Result
where F: Write + ?Sized,

Write a statement terminator

source

pub fn write_function_definition_terminator<F>(&mut self, f: &mut F) -> Result
where F: Write + ?Sized,

Write a function definition terminator

source

pub fn write_statement_opening_parenthesis<F>(&mut self, f: &mut F) -> Result
where F: Write + ?Sized,

Write an opening parenthesis for a statement

source

pub fn write_statement_closing_parenthesis<F>(&mut self, f: &mut F) -> Result
where F: Write + ?Sized,

Write a closing parenthesis for a statement

Trait Implementations§

source§

impl<'s> Clone for FormattingState<'s>

source§

fn clone(&self) -> FormattingState<'s>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'s> Debug for FormattingState<'s>

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for FormattingState<'static>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'s> From<&'s FormattingSettings> for FormattingState<'s>

source§

fn from(settings: &'s FormattingSettings) -> Self

Converts to this type from the input type.
source§

impl<'s> PartialEq for FormattingState<'s>

source§

fn eq(&self, other: &FormattingState<'s>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'s> Copy for FormattingState<'s>

source§

impl<'s> Eq for FormattingState<'s>

source§

impl<'s> StructuralPartialEq for FormattingState<'s>

Auto Trait Implementations§

§

impl<'s> Freeze for FormattingState<'s>

§

impl<'s> RefUnwindSafe for FormattingState<'s>

§

impl<'s> Send for FormattingState<'s>

§

impl<'s> Sync for FormattingState<'s>

§

impl<'s> Unpin for FormattingState<'s>

§

impl<'s> UnwindSafe for FormattingState<'s>

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.