pub struct Expense {
pub date: String,
pub description: String,
pub expense_type: String,
pub amount: f64,
}Expand description
The Expense struct; helps reading/writing data in a structured manner. It reflects the schema of the database.
Fields§
§date: String§description: String§expense_type: String§amount: f64Implementations§
Source§impl Expense
impl Expense
pub fn new( date: String, description: String, expense_type: String, amount: f64, ) -> Self
Sourcepub fn add_expense() -> Result<(), Box<dyn Error>>
pub fn add_expense() -> Result<(), Box<dyn Error>>
Function to add and expense to the database.
Takes input from stdin for date, description, expense type and amount.
Support YYYY-MM-DD and YYYY/MM/DD date format as input.
For amount no denoination is expected as of now.
Sourcepub fn edit_expenses(file_name: &str) -> Result<(), Box<dyn Error>>
pub fn edit_expenses(file_name: &str) -> Result<(), Box<dyn Error>>
Allows editing the database by specifying an EDITOR environment variable. By default its nano.
Sourcepub fn append_to_csv(
file_name: &str,
expense: &Expense,
) -> Result<(), Box<dyn Error>>
pub fn append_to_csv( file_name: &str, expense: &Expense, ) -> Result<(), Box<dyn Error>>
Allows adding data to the end of the database
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Expense
impl RefUnwindSafe for Expense
impl Send for Expense
impl Sync for Expense
impl Unpin for Expense
impl UnwindSafe for Expense
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