Skip to content

Commit

Permalink
wip: docs
Browse files Browse the repository at this point in the history
  • Loading branch information
SteelAlloy committed Sep 15, 2024
1 parent 923a311 commit 1b2ff7b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Thumbor for rust

## Usage

```rust
use thumbor::Server;

let server = Server::new_secured("http://localhost:8888", "my-security-key");

let builder = server.url_builder()
.resize((300, 200))
.smart(true)
.build();

let url = builder.build("/path/to/my/image.jpg");
```
6 changes: 6 additions & 0 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ impl From<String> for Security {
}
}

/// ```
/// use thumbor::Server;
///
/// let server = Server::new_secured("http://localhost:8888", "my-security-key");
/// let server = Server::new_unsafe("http://localhost:8888"); // Don't use this in production !
/// ```
#[derive(Default, Clone)]
pub struct Server {
pub origin: String,
Expand Down
16 changes: 10 additions & 6 deletions src/settings/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,9 @@ pub enum Filter {
},
}

impl fmt::Display for Filter {
#[allow(clippy::too_many_lines)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let args = match self {
impl Filter {
fn args(&self) -> Vec<String> {
match self {
Filter::AutoJPG
| Filter::Cover
| Filter::Equalize
Expand Down Expand Up @@ -216,13 +215,18 @@ impl fmt::Display for Filter {
}
args
}
};
}
}
}

impl fmt::Display for Filter {
#[allow(clippy::too_many_lines)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let name = match self {
Filter::Custom { name, .. } => name,
_ => self.as_ref(),
};

write!(f, "{name}({})", args.join(","))
write!(f, "{name}({})", self.args().join(","))
}
}

0 comments on commit 1b2ff7b

Please sign in to comment.