FormattingState

Struct FormattingState 

Source
pub struct FormattingState<'s> {
    pub settings: &'s FormattingSettings,
    /* private fields */
}
Expand description

Formatting state of the GLSL transpiler

Fields§

§settings: &'s FormattingSettings

Formatting settings

Implementations§

Source§

impl<'s> FormattingState<'s>

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

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 duplicate 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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> 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.