https://github.com/dryrust/tldr.rs
Rust abstractions for TL;DR summarization using the five Ws: who? what? when? where? why?
https://github.com/dryrust/tldr.rs
rust rust-crate tldr
Last synced: 9 months ago
JSON representation
Rust abstractions for TL;DR summarization using the five Ws: who? what? when? where? why?
- Host: GitHub
- URL: https://github.com/dryrust/tldr.rs
- Owner: dryrust
- License: unlicense
- Created: 2025-08-04T11:02:34.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2025-08-06T06:56:14.000Z (10 months ago)
- Last Synced: 2025-08-11T15:30:17.179Z (10 months ago)
- Topics: rust, rust-crate, tldr
- Language: Rust
- Homepage: https://crates.io/crates/tldr-traits
- Size: 34.2 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- Codeowners: .github/CODEOWNERS
- Authors: AUTHORS
Awesome Lists containing this project
README
# TL;DR.rs
[](https://unlicense.org)
[](https://blog.rust-lang.org/2025/02/20/Rust-1.85.0/)
[](https://crates.io/crates/tldr-traits)
[](https://docs.rs/tldr-traits)
[Rust] abstractions for [TL;DR] summarization using the [five Ws]:
*who?* *what?* *when?* *where?* *why?*
## ✨ Features
- Provides the [`Tldr`](#tldr) trait for generating TL;DR summaries.
- Provides the [`ToTldr`](#totldr) trait for converting objects into TL;DR
summaries.
- Supports multilingual TL;DR generation while defaulting to English.
- Zero required dependencies, only optional integrations with [Serde] & [Bon].
- Adheres to the Rust API Guidelines in its [naming conventions].
- 100% free and unencumbered public domain software.
## 🛠️ Prerequisites
- [Rust] 1.85+ (2024 edition)
## ⬇️ Installation
### Installation via Cargo
```bash
cargo add tldr-traits --rename tldr
```
### Installation in `Cargo.toml` (with all features enabled)
```toml
[dependencies]
tldr = { version = "0", package = "tldr-traits" }
```
### Installation in `Cargo.toml` (with only specific features enabled)
```toml
[dependencies]
tldr = { version = "0", package = "tldr-traits", default-features = false, features = ["serde"] }
```
## 👉 Examples
### Importing the Library
```rust,ignore
use tldr::{Tldr, TldrContext, TldrLanguage, TldrResult, TldrSummary, ToTldr};
```
### Implementing the Trait
```rust,ignore
struct Rectangle {
width: u32,
height: u32,
}
impl Tldr for Rectangle {
type Error = Box;
fn what(&self, _ctx: &TldrContext) -> TldrResult {
Ok(Some(format!("A rectangle with a width of {} and a height of {}.", self.width, self.height)))
}
}
```
## 📚 Reference
- [`Tldr`](#tldr)
- [`TldrContext`](#tldrcontext)
- [`TldrLanguage`](#tldrlanguage)
- [`TldrResult`](#tldrresult)
- [`TldrSummary`](#tldrsummary)
- [`ToTldr`](#totldr)
### [`Tldr`]
```rust,ignore
pub trait Tldr {
fn who(&self, ctx: &TldrContext) -> TldrResult;
fn what(&self, ctx: &TldrContext) -> TldrResult;
fn when(&self, ctx: &TldrContext) -> TldrResult;
fn where(&self, ctx: &TldrContext) -> TldrResult;
fn why(&self, ctx: &TldrContext) -> TldrResult;
fn whence(&self, ctx: &TldrContext) -> TldrResult;
fn how(&self, ctx: &TldrContext) -> TldrResult;
}
```
### [`TldrContext`]
```rust,ignore
pub struct TldrContext {
pub language: TldrLanguage,
}
```
### [`TldrLanguage`]
```rust,ignore
pub enum TldrLanguage {
#[default]
English,
// ...
Other(String),
}
```
### [`TldrResult`]
```rust,ignore
pub type TldrResult> =
Result, E>;
```
### [`TldrSummary`]
```rust,ignore
pub struct TldrSummary {
pub who: Option,
pub what: Option,
pub when: Option,
pub where: Option,
pub why: Option,
pub whence: Option,
pub how: Option,
}
```
### [`ToTldr`]
```rust,ignore
pub trait ToTldr {
fn to_tldr(&self) -> Box>;
}
```
## 👨💻 Development
```bash
git clone https://github.com/dryrust/tldr.rs.git
```
---
[](https://x.com/intent/post?url=https://github.com/dryrust/tldr.rs&text=TL;DR.rs)
[](https://reddit.com/submit?url=https://github.com/dryrust/tldr.rs&title=TL;DR.rs)
[](https://news.ycombinator.com/submitlink?u=https://github.com/dryrust/tldr.rs&t=TL;DR.rs)
[](https://www.facebook.com/sharer/sharer.php?u=https://github.com/dryrust/tldr.rs)
[](https://www.linkedin.com/sharing/share-offsite/?url=https://github.com/dryrust/tldr.rs)
[Bon]: https://crates.io/crates/bon
[Rust]: https://rust-lang.org
[Serde]: https://crates.io/crates/serde
[TL;DR]: https://en.wikipedia.org/wiki/TL;DR
[five Ws]: https://en.wikipedia.org/wiki/Five_Ws
[naming conventions]: https://rust-lang.github.io/api-guidelines/naming.html
[`Tldr`]: https://docs.rs/tldr-traits/latest/tldr_traits/trait.Tldr.html
[`TldrContext`]: https://docs.rs/tldr-traits/latest/tldr_traits/struct.TldrContext.html
[`TldrLanguage`]: https://docs.rs/tldr-traits/latest/tldr_traits/enum.TldrLanguage.html
[`TldrResult`]: https://docs.rs/tldr-traits/latest/tldr_traits/type.TldrResult.html
[`TldrSummary`]: https://docs.rs/tldr-traits/latest/tldr_traits/struct.TldrSummary.html
[`ToTldr`]: https://docs.rs/tldr-traits/latest/tldr_traits/trait.ToTldr.html