Skip to main content

GeneratorExt

Trait GeneratorExt 

Source
pub trait GeneratorExt: IsA<Generator> + 'static {
Show 15 methods // Provided methods fn indent(&self) -> u32 { ... } fn indent_char(&self) -> char { ... } fn is_pretty(&self) -> bool { ... } fn root(&self) -> Option<Node> { ... } fn set_indent(&self, indent_level: u32) { ... } fn set_indent_char(&self, indent_char: char) { ... } fn set_pretty(&self, is_pretty: bool) { ... } fn set_root(&self, node: &Node) { ... } fn to_data(&self) -> (GString, usize) { ... } fn to_file(&self, filename: impl AsRef<Path>) -> Result<(), Error> { ... } fn to_stream( &self, stream: &impl IsA<OutputStream>, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(), Error> { ... } fn connect_indent_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_indent_char_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_pretty_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_root_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... }
}
Expand description

Trait containing all Generator methods.

§Implementors

Generator

Provided Methods§

Source

fn indent(&self) -> u32

Retrieves the value set using set_indent().

§Returns

the number of repetitions per indentation level

Source

fn indent_char(&self) -> char

Retrieves the value set using set_indent_char().

§Returns

the character to be used when indenting

Source

fn is_pretty(&self) -> bool

Retrieves the value set using set_pretty().

§Returns

TRUE if the generated JSON should be pretty-printed, and FALSE otherwise

Source

fn root(&self) -> Option<Node>

Retrieves a pointer to the root node set using set_root().

§Returns

the root node

Source

fn set_indent(&self, indent_level: u32)

Sets the number of repetitions for each indentation level.

§indent_level

the number of repetitions of the indentation character that should be applied when pretty printing

Source

fn set_indent_char(&self, indent_char: char)

Sets the character to be used when indenting.

§indent_char

a Unicode character to be used when indenting

Source

fn set_pretty(&self, is_pretty: bool)

Sets whether the generated JSON should be pretty printed.

Pretty printing will use indentation character specified in the indent-char property and the spacing specified in the indent property.

§is_pretty

whether the generated string should be pretty printed

Source

fn set_root(&self, node: &Node)

Sets the root of the JSON data stream to be serialized by the given generator.

The passed node is copied by the generator object, so it can be safely freed after calling this function.

§node

the root node

Source

fn to_data(&self) -> (GString, usize)

Generates a JSON data stream from @self and returns it as a buffer.

§Returns

a newly allocated string holding a JSON data stream

§length

return location for the length of the returned buffer

Source

fn to_file(&self, filename: impl AsRef<Path>) -> Result<(), Error>

Creates a JSON data stream and puts it inside filename, overwriting the file’s current contents.

This operation is atomic, in the sense that the data is written to a temporary file which is then renamed to the given filename.

§filename

the path to the target file

§Returns

true if saving was successful.

Source

fn to_stream( &self, stream: &impl IsA<OutputStream>, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(), Error>

Outputs JSON data and writes it (synchronously) to the given stream.

§stream

the output stream used to write the JSON data

§cancellable

a GCancellable

§Returns

whether the write operation was successful

Source

fn connect_indent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

Source

fn connect_indent_char_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Source

fn connect_pretty_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

Source

fn connect_root_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§