3 releases
new 0.1.2 | Feb 21, 2025 |
---|---|
0.1.1 | Feb 21, 2025 |
0.1.0 | Feb 21, 2025 |
#482 in Database interfaces
25 downloads per month
24KB
157 lines
Trekname
A Rust library containing Star Trek character names and descriptions from various series including The Original Series, The Next Generation, Deep Space Nine, Voyager, Enterprise, and Discovery.
Features
- Static compile-time character database using
phf_map
- Efficient lookups for character descriptions
- Complete collection of major characters from across the Star Trek universe
- Memory-efficient implementation using static strings
- Thread-safe access to character data
Usage
Add this to your Cargo.toml
:
[dependencies]
trekname = "0.1.1"
Example
use trekname::{get_description, character_exists, get_all_names};
fn main() {
// Get a character's description
if let Some(description) = get_description("Kirk") {
println!("Kirk: {}", description);
}
// Check if a character exists
if character_exists("Picard") {
println!("Picard exists in the database!");
}
// Get all character names
let names = get_all_names();
println!("Total characters: {}", names.len());
}
API
Functions
get_description(name: &str) -> Option<&'static str>
: Returns the description for a given character name, if it existscharacter_exists(name: &str) -> bool
: Returns true if the character exists in the databaseget_all_names() -> Vec<&'static str>
: Returns a vector of all character names
Static Data
TREK_DESCRIPTIONS
: A staticphf::Map
containing all character names and descriptions
License
This project is licensed under the MIT License.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Dependencies
~0.6–1MB
~23K SLoC