| Crates.io | semire_core |
| lib.rs | semire_core |
| version | 0.1.3 |
| created_at | 2026-01-17 18:14:14.926494+00 |
| updated_at | 2026-01-17 18:37:59.249787+00 |
| description | An extension to my former semire_read crate now with more functionality |
| homepage | |
| repository | https://github.com/serenebliss0/Testing-repo/tree/main/semire-core-utils |
| max_upload_size | |
| id | 2050895 |
| size | 6,390 |
A small Rust utility crate that makes reading input and basic file operations easier and less repetitive.
This crate provides:
stdinResultPerfect for small projects, CLIs, learning Rust, or when you’re tired of rewriting the same boilerplate.
Add this to your Cargo.toml:
[dependencies]
semire-core = "0.1.0"
The Readable trait allows you to read user input into any type that implements FromStr.
use semire_core::Readable;
let age: u32 = Readable::read();
let username: String = Readable::read();
Behavior:
Create a file with optional overwrite behavior:
use semire_core::create_file;
// Overwrite if the file already exists
create_file("data.txt", true)?;
// Keep existing contents if the file exists
create_file("data.txt", false)?;
Write text data to a file with append or overwrite control:
use semire_core::write_data;
write_data(
"clients.serenity",
"New client added",
true, // append to file
false, // do not overwrite
)?;
Notes:
Read and print the contents of a file:
use semire_core::read_data;
read_data("clients.serenity")?;
Details:
from_utf8_lossyuse semire_core::{Readable, create_file, write_data, read_data};
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Enter your name:");
let name: String = Readable::read();
create_file("users.txt", true)?;
write_data("users.txt", &name, true, false)?;
read_data("users.txt")?;
Ok(())
}
Most functions return Result, allowing easy propagation with ?:
fn main() -> Result<(), Box<dyn std::error::Error>> {
create_file("example.txt", true)?;
Ok(())
}
OpenOptions for flexible file handlingBox<dyn Error> where flexibility is preferredMIT License
If this crate saves you from rewriting the same code twice, it’s doing its job 😌 More features coming soon : )