A simple terminal-based contact management system written in Rust.
- Add new contacts with name, phone number, and email.
- Display all saved contacts in a formatted list.
- Search for a contact by name using a case-insensitive search.
- Edit existing contacts by updating their phone number or email.
- Delete contacts from the list.
- Save contacts to a file (
contacts.csv
) and load them at startup.
To run this application, you'll need:
- Rust (1.70 or higher)
- A terminal or command prompt to execute the program.
-
Clone this repository:
git clone https://github.com/your-username/contacts_rust.git cd contacts_rust
-
Build the project:
cargo build --release
-
Run the executable
./target/release/contacts_rust
-
Contact
Struct: Represents a contact with the following fields:name
: The name of the contact (aString
).phone_number
: The contact's phone number (aString
).email
: The contact's email address (aString
).- Methods:
serialize
: Converts aContact
into a CSV-compatible string.deserialize
: Converts a CSV string into aContact
.
-
Functions:
add_contact
: Adds a new contact to the list and saves it to the file.display_contacts
: Prints all saved contacts in a formatted output.search_contact
: Searches for a contact by name using case-insensitive binary search.edit_contact
: Updates an existing contact's phone number or email.delete_contact
: Removes a contact from the list by name.load_contacts
: Loads contact data fromcontacts.csv
at program start.save_contacts
: Saves all contacts tocontacts.csv
before exiting.check_for_duplicates
: Checks if a new contact already exists in the list.
-
File Storage:
- Contacts are stored in a CSV file (
contacts.csv
) where each contact is a line in the format:
name,phone_number,email
- The file is read when the application starts and written to whenever changes are made.
- Contacts are stored in a CSV file (
-
Main Menu: The
main
function handles user interaction and allows the selection of options like adding, editing, or deleting contacts.
- TUI with ratatui
This project is licensed under the MIT License.
You are free to use, modify, and distribute this software, provided that the original copyright notice and permission notice are included in all copies or substantial portions of the software.
See the LICENSE file for full license details.