#shortener #link-shortener

link_rs

Generate hash-id based URLs and QR codes for use in URL shortening services

3 releases

0.1.2 Jun 16, 2022
0.1.1 Jun 16, 2022
0.1.0 Jun 16, 2022

#12 in #shortener

BSD-3-Clause

14KB
110 lines

link-rs

Generate hash-id based URLs and QR codes for use in URL shortening services.

🔍 About

A simple implementation of a URL generation module. Allows for qr-code generation using the qrcode library.

🔋 Usage

Basic Example:

mod link_rs::LinkGenerator


fn main() {
    let mut link_gen = LinkGenerator::new("/some/redirect", 10);

    let link = link_gen::generate_url()
    println!("{:?}", link) // Link { key: "vq5ejng0p6", url: "/some/redirect/vq5ejng0p6" }
}

To see a complete implementation of a url shortening service, please take a look at the actix-web example.

🛠️ Add via cargo.toml

link_rs = { version = "0.1.2", features = ["qrcode"] }

🔬 Test using cargo test

cargo test

lib.rs:

link-rs

Generate hash-id based URLs and QR codes for use in URL shortening services.

Basic example:

mod link_rs::LinkGenerator

fn main() {
    let mut link_gen = LinkGenerator::new("/some/redirect", 10);
    
    let link = link_gen::generate_url()
    println!("{:?}",link) // Link { key: "vq5ejng0p6", url: "/some/redirect/vq5ejng0p6" }
}

To see a complete implementation of a url shortening service, please take a look at the actix-web example.

Dependencies

~2MB
~36K SLoC