pub struct FileSection {
pub name: String,
pub content: Vec<Box<dyn FileSectionContent>>,
/* private fields */
}Fields§
§name: StringFile section name.
content: Vec<Box<dyn FileSectionContent>>File section content.
Implementations§
Source§impl FileSection
impl FileSection
Sourcepub fn from_template(template: &SectionTemplate) -> Result<Self>
pub fn from_template(template: &SectionTemplate) -> Result<Self>
Creates a new FileSection from a template.
Sourcepub fn indented_branch(&mut self, name: impl Into<String>) -> &mut Self
pub fn indented_branch(&mut self, name: impl Into<String>) -> &mut Self
Gets or creates, if it doesn’t exist, an indented branch.
Sourcepub fn indexed_write<S: Into<String>>(&mut self, index: usize, content: S)
pub fn indexed_write<S: Into<String>>(&mut self, index: usize, content: S)
Writes the content to the file section at the specified index.
Sourcepub fn indexed_writeln<S: Into<String>>(&mut self, index: usize, content: S)
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.
Sourcepub fn writeln<S: Into<String>>(&mut self, content: S)
pub fn writeln<S: Into<String>>(&mut self, content: S)
Writes the content to the file buffer and adds a new line.
Sourcepub fn indentation(&mut self, indentation_level: usize) -> &mut Self
pub fn indentation(&mut self, indentation_level: usize) -> &mut Self
Sets the indentation level.
Trait Implementations§
Source§impl AddBranch<FileSection> for FileSection
impl AddBranch<FileSection> for FileSection
Source§fn add_branch(&mut self, branch: FileSection) -> &mut FileSection
fn add_branch(&mut self, branch: FileSection) -> &mut FileSection
Add a value to the branches of a type.
Source§impl AsMut<FileSection> for File
impl AsMut<FileSection> for File
Source§fn as_mut(&mut self) -> &mut FileSection
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
impl AsRef<FileSection> for File
Source§fn as_ref(&self) -> &FileSection
fn as_ref(&self) -> &FileSection
Converts this type into a shared reference of the (usually inferred) input type.
Source§impl Borrow<FileSection> for File
impl Borrow<FileSection> for File
Source§fn borrow(&self) -> &FileSection
fn borrow(&self) -> &FileSection
Immutably borrows from an owned value. Read more
Source§impl BorrowMut<FileSection> for File
impl BorrowMut<FileSection> for File
Source§fn borrow_mut(&mut self) -> &mut FileSection
fn borrow_mut(&mut self) -> &mut FileSection
Mutably borrows from an owned value. Read more
Source§impl Debug for FileSection
impl Debug for FileSection
Source§impl Display for FileSection
impl Display for FileSection
Source§impl FileSectionContent for FileSection
impl FileSectionContent for FileSection
fn as_section(&self) -> Option<&FileSection>
fn as_section_mut(&mut self) -> Option<&mut FileSection>
fn as_string(&self) -> Option<&String>
fn as_string_mut(&mut self) -> Option<&mut String>
Source§impl From<String> for FileSection
impl From<String> for FileSection
Source§impl<'a> HasBranches<&'a FileSection> for &'a FileSection
impl<'a> HasBranches<&'a FileSection> for &'a FileSection
Source§fn branches_impl(self) -> impl Iterator<Item = &'a FileSection>
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
impl<'a> HasBranches<&'a mut FileSection> for &'a mut FileSection
Source§fn branches_impl(self) -> impl Iterator<Item = &'a mut FileSection>
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
impl<'a> HasGetMut<'a> for FileSection
Source§impl HasPathSegment for FileSection
impl HasPathSegment for FileSection
Source§impl<'a> TryFrom<&'a Box<dyn FileSectionContent>> for &'a FileSection
impl<'a> TryFrom<&'a Box<dyn FileSectionContent>> for &'a FileSection
Auto Trait Implementations§
impl !RefUnwindSafe for FileSection
impl !Send for FileSection
impl !Sync for FileSection
impl !UnwindSafe for FileSection
impl Freeze for FileSection
impl Unpin for FileSection
impl UnsafeUnpin for FileSection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> HasBranchesAPI for T
impl<T> HasBranchesAPI for T
Source§fn branches_impl2<T>(self) -> impl Iterator<Item = T>where
Self: Sized + HasBranches<T>,
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
impl<'a, T> HasBranchesAPIV2<'a> for T
Source§fn branches<T>(&'a self) -> impl Iterator<Item = T>where
&'a Self: HasBranches<T>,
T: 'a,
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,
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.
fn all_branches<T>(&'a self) -> impl Iterator<Item = T>
fn all_branches_mut<T>(&'a mut self) -> impl Iterator<Item = T>
Source§impl<T> HasGet for T
impl<T> HasGet for T
Source§impl<'a, T> HasGetAPI<'a> for T
impl<'a, T> HasGetAPI<'a> for T
Source§impl<'a, T> HasRelative<'a> for T
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>,
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
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>,
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.