Skip to main content

FileSection

Struct FileSection 

Source
pub struct FileSection {
    pub name: String,
    pub content: Vec<Box<dyn FileSectionContent>>,
    /* private fields */
}

Fields§

§name: String

File section name.

§content: Vec<Box<dyn FileSectionContent>>

File section content.

Implementations§

Source§

impl FileSection

Source

pub fn new(name: impl Into<String>) -> Self

Creates a new FileSection.

Source

pub fn from_template(template: &SectionTemplate) -> Result<Self>

Creates a new FileSection from a template.

Source

pub fn indented_branch(&mut self, name: impl Into<String>) -> &mut Self

Gets or creates, if it doesn’t exist, an indented branch.

Source

pub fn indexed_write<S: Into<String>>(&mut self, index: usize, content: S)

Writes the content to the file section at the specified index.

Source

pub fn indexed_writeln<S: Into<String>>(&mut self, index: usize, content: S)

Writes the content to the file section at the specified index and adds a new line.

Source

pub fn write<S: Into<String>>(&mut self, content: S)

Writes the content to the file buffer.

Source

pub fn writeln<S: Into<String>>(&mut self, content: S)

Writes the content to the file buffer and adds a new line.

Source

pub fn indent(&mut self) -> &mut Self

Increase the indentation level by 1.

Source

pub fn dedent(&mut self) -> &mut Self

Decrease the indentation level by 1.

Source

pub fn indentation(&mut self, indentation_level: usize) -> &mut Self

Sets the indentation level.

Trait Implementations§

Source§

impl AddBranch<FileSection> for FileSection

Source§

fn add_branch(&mut self, branch: FileSection) -> &mut FileSection

Add a value to the branches of a type.
Source§

impl AsMut<FileSection> for File

Source§

fn as_mut(&mut self) -> &mut FileSection

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<FileSection> for File

Source§

fn as_ref(&self) -> &FileSection

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<FileSection> for File

Source§

fn borrow(&self) -> &FileSection

Immutably borrows from an owned value. Read more
Source§

impl BorrowMut<FileSection> for File

Source§

fn borrow_mut(&mut self) -> &mut FileSection

Mutably borrows from an owned value. Read more
Source§

impl Debug for FileSection

Source§

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

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

impl Display for FileSection

Source§

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

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

impl FileSectionContent for FileSection

Source§

impl From<String> for FileSection

Source§

fn from(name: String) -> Self

Converts to this type from the input type.
Source§

impl<'a> HasBranches<&'a FileSection> for &'a FileSection

Source§

fn branches_impl(self) -> impl Iterator<Item = &'a FileSection>

This is the method that should be implemented to provide a way to iterate over the branches of a type. It’s discouraged to use this method directly. Instead, use the branches method from the HasBranchesAPIV2 trait.
Source§

impl<'a> HasBranches<&'a mut FileSection> for &'a mut FileSection

Source§

fn branches_impl(self) -> impl Iterator<Item = &'a mut FileSection>

This is the method that should be implemented to provide a way to iterate over the branches of a type. It’s discouraged to use this method directly. Instead, use the branches method from the HasBranchesAPIV2 trait.
Source§

impl<'a> HasGetMut<'a> for FileSection

Source§

fn get_mut<T>(&'a mut self, segment: impl Into<String>) -> Option<T>
where &'a mut Self: HasGet + HasBranches<T>, T: HasPathSegment + 'a,

Gets a branch by its path segment mutably.
Source§

impl HasPathSegment for FileSection

Source§

fn path_segment(&self) -> String

Gets the path segment of the type.
Source§

fn is(&self, identifier: impl PartialEq<String>) -> bool

Checks if the type is identified by the given path segment.
Source§

impl<'a> TryFrom<&'a Box<dyn FileSectionContent>> for &'a FileSection

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(value: &'a Box<dyn FileSectionContent>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a mut Box<dyn FileSectionContent>> for &'a mut FileSection

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from( value: &'a mut Box<dyn FileSectionContent>, ) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<'a, T> HasBranch<'a> for T

Source§

fn branch<T>(&'a mut self, segment: impl Into<String>) -> &'a mut T
where &'a mut Self: HasGet + HasBranches<&'a mut T>, Self: Sized + AddBranch<T> + HasGetMut<'a>, T: HasPathSegment + 'a, String: Into<T>,

Source§

impl<T> HasBranchesAPI for T

Source§

fn branches_impl2<T>(self) -> impl Iterator<Item = T>
where Self: Sized + HasBranches<T>,

This is used internally. Should use branches instead.
Source§

impl<'a, T> HasBranchesAPIV2<'a> for T

Source§

fn branches<T>(&'a self) -> impl Iterator<Item = T>
where &'a Self: HasBranches<T>, T: 'a,

Iterates over the branches of a type.
Source§

fn branches_mut<T>(&'a mut self) -> impl Iterator<Item = T>
where &'a mut Self: HasBranches<T>, T: 'a,

Iterates over the branches of a type mutably.
Source§

fn all_branches<T>(&'a self) -> impl Iterator<Item = T>
where &'a Self: HasBranches<T>, T: 'a + HasBranches<T> + Copy,

Source§

fn all_branches_mut<T>(&'a mut self) -> impl Iterator<Item = T>
where &'a mut Self: HasBranches<T>, T: 'a + HasBranches<T> + Copy,

Source§

impl<T> HasGet for T

Source§

fn get_impl<T>(self, segment: impl Into<String>) -> Option<T>
where Self: Sized + HasBranches<T>, T: HasPathSegment,

Gets a branch by its path segment. It’s discouraged to use this method directly. Instead, use the get and get_mut method from the HasGetAPI trait.
Source§

impl<'a, T> HasGetAPI<'a> for T

Source§

fn get<T>(&'a self, segment: impl Into<String>) -> Option<T>
where &'a Self: HasGet + HasBranches<T>, T: HasPathSegment + 'a,

Gets a branch by its path segment.
Source§

impl<'a, T> HasRelative<'a> for T

Source§

fn relative<K>(&'a self, path: impl IntoIterator<Item = K>) -> Option<Self>
where K: Into<String>, Self: KnowsVisitor<Visitor = Self> + Clone + HasRoot + HasParent + HasPathSegment, &'a Self: HasBranches<Self>,

Gets a relative path. “self”, “root”, and “super” are reserved path segments. “self” is the current object, “root” is the root object, and “super” is the parent object.
Source§

impl<'a, T> HasRelativeMut<'a> for T

Source§

unsafe fn relative_mut<K>( &'a mut self, path: impl IntoIterator<Item = K>, ) -> Option<Self>
where K: Into<String>, Self: Sized + KnowsVisitor<VisitorMut = Self> + UnsafeClone + HasRootMut + HasParentMut + HasPathSegment, &'a mut Self: HasBranches<Self>,

Gets a relative path mutably. “self”, “root”, and “super” are reserved path segments. “self” is the current object, “root” is the root object, and “super” is the parent object.
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.