Skip to content

Commit ad38002

Browse files
committed
wip
1 parent 8c7b28e commit ad38002

File tree

7 files changed

+200
-159
lines changed

7 files changed

+200
-159
lines changed

.clippy.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
too-many-arguments-threshold = 10

.github/workflows/tests.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: tests
2+
on: [push, pull_request]
3+
jobs:
4+
check:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- name: Check out
8+
uses: actions/checkout@v3
9+
- name: Install Rust
10+
uses: actions-rs/toolchain@v1
11+
with:
12+
profile: minimal
13+
toolchain: stable
14+
override: true
15+
components: rustfmt, clippy
16+
- name: Set up cargo cache
17+
uses: actions/cache@v3
18+
continue-on-error: false
19+
with:
20+
path: |
21+
~/.cargo/bin/
22+
~/.cargo/registry/index/
23+
~/.cargo/registry/cache/
24+
~/.cargo/git/db/
25+
target/
26+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
27+
restore-keys: ${{ runner.os }}-cargo-
28+
- name: Lint
29+
run: |
30+
rustfmt **/*.rs
31+
cargo clippy --all -- -D warnings
32+
- name: Install cargo check tools
33+
run: |
34+
cargo install --locked cargo-outdated || true
35+
- name: Check
36+
run: |
37+
cargo outdated --exit-code 1
38+
rm -rf ~/.cargo/advisory-db
39+
- name: Test
40+
run: cargo test --all

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# [Sqids PostgreSQL](https://sqids.org/postgresql)
22

3+
[![Github Actions](https://img.shields.io/github/actions/workflow/status/sqids/sqids-postgresql/tests.yml)](https://github.com/sqids/sqids-postgresql/actions)
4+
35
[Sqids](https://sqids.org/postgresql) (*pronounced "squids"*) is a small library that lets you **generate unique IDs from numbers**. It's good for link shortening, fast & URL-safe ID generation and decoding back into numbers for quicker database lookups.
46

57
Features:

rustfmt.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
max_width = 100
2+
comment_width = 100
3+
hard_tabs = true
4+
edition = "2021"
5+
reorder_imports = true
6+
imports_granularity = "Crate"
7+
use_small_heuristics = "Max"
8+
wrap_comments = true
9+
binop_separator = "Back"
10+
trailing_comma = "Vertical"
11+
trailing_semicolon = true
12+
use_field_init_shorthand = true
13+
format_macro_bodies = true
14+
format_code_in_doc_comments = true

src/error.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,28 @@ use thiserror::Error;
44

55
#[derive(Error, Debug, Eq, PartialEq)]
66
pub enum Error {
7-
#[error("Min length has to be between 0 and 255")]
8-
MinLengthRange,
9-
#[error("Numbers cannot be negative")]
10-
NegativeNumbers,
7+
#[error("Min length has to be between 0 and 255")]
8+
MinLengthRange,
9+
#[error("Numbers cannot be negative")]
10+
NegativeNumbers,
1111
}
1212

1313
pub enum PgError {
14-
SqidsError(sqids::Error),
15-
CustomError(Error),
14+
SqidsError(sqids::Error),
15+
CustomError(Error),
1616
}
1717

1818
impl fmt::Display for PgError {
19-
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
20-
match self {
21-
PgError::SqidsError(err) => error!("{}", err),
22-
PgError::CustomError(err) => error!("{}", err),
23-
}
24-
}
19+
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
20+
match self {
21+
PgError::SqidsError(err) => error!("{}", err),
22+
PgError::CustomError(err) => error!("{}", err),
23+
}
24+
}
2525
}
2626

2727
impl From<sqids::Error> for PgError {
28-
fn from(err: sqids::Error) -> Self {
29-
PgError::SqidsError(err)
30-
}
28+
fn from(err: sqids::Error) -> Self {
29+
PgError::SqidsError(err)
30+
}
3131
}

0 commit comments

Comments
 (0)