Crates.io | metadata-gen |
lib.rs | metadata-gen |
version | 0.0.1 |
source | src |
created_at | 2024-10-05 20:58:19.448026 |
updated_at | 2024-10-05 20:58:19.448026 |
description | A powerful Rust library for extracting, validating, and processing metadata in YAML, TOML, and JSON formats from any content or data file. |
homepage | https://metadata-gen.com/ |
repository | https://github.com/sebastienrousseau/metadata-gen |
max_upload_size | |
id | 1398462 |
size | 218,186 |
A powerful Rust library for extracting, validating, and processing metadata in YAML, TOML, and JSON formats from any content or data file.
• Website • Documentation • Report Bug • Request Feature • Contributing Guidelines
metadata-gen
is a robust Rust library designed for extracting, validating, and processing metadata from various content and data file formats. It focuses on the following key areas:
Key features include:
Value
enummetadata-gen
aims to provide a stable and powerful foundation for metadata management across all platforms supported by Rust.
Add this to your Cargo.toml
:
[dependencies]
metadata-gen = "0.0.1"
Here are some examples of how to use the library:
use metadata_gen::extract_and_prepare_metadata;
let content = r#"---
title: My Post
description: A sample post
keywords: rust, metadata, extraction
---
Content here"#;
let result = extract_and_prepare_metadata(content);
if let Ok((metadata, keywords, meta_tags)) = result {
println!("Metadata: {:?}", metadata);
println!("Keywords: {:?}", keywords);
println!("Meta tags: {}", meta_tags);
}
use metadata_gen::utils::{escape_html, unescape_html};
let original = "Hello <World> & \"Friends\"";
let escaped = escape_html(original);
let unescaped = unescape_html(&escaped);
println!("Original: {}", original);
println!("Escaped: {}", escaped);
println!("Unescaped: {}", unescaped);
use metadata_gen::utils::async_extract_metadata_from_file;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let (metadata, keywords, meta_tags) = async_extract_metadata_from_file("./examples/example.md").await?;
println!("Metadata: {:?}", metadata);
println!("Keywords: {:?}", keywords);
println!("Meta tags: {}", meta_tags);
Ok(())
}
For full API documentation, please visit docs.rs/metadata-gen.
To run the examples, clone the repository and use the following command:
cargo run --example example_name
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under either of
at your option.
Special thanks to all contributors who have helped build the metadata-gen
library.