//! This module contains the `FileBuffer` struct and associated implementations, //! which is used to represent the file buffer's contents and current file path. //! //! This file is part of sued. //! //! Visit `main.rs` and `lib.rs` for context and usage. //! //! sued is free software licensed under the Apache License, Version 2.0. /// This struct is used to represent the file buffer. /// `contents` will contain the text contents of the file as a Vec, /// and `file_path` will, obviously, contain the file path. /// **All instances of this struct should be mutable to work with process_command.** #[derive(Debug, Clone, Default)] pub struct FileBuffer { pub contents: Vec, pub file_path: Option, } impl FileBuffer { pub fn new() -> FileBuffer { FileBuffer { contents: Vec::new(), file_path: None, } } pub fn from(contents: Vec) -> Self { FileBuffer { contents, file_path: None, } } } impl std::fmt::Display for FileBuffer { fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result { write!(fmt, "{}", self.contents.join("\n")) } }