7 releases (2 stable)

Uses new Rust 2021

1.1.0 Jun 26, 2022
1.0.0 Mar 22, 2021
0.4.0 Aug 30, 2020
0.3.0 Nov 1, 2019
0.1.1 Oct 23, 2019

#247 in Encoding

Download history 46/week @ 2022-04-26 34/week @ 2022-05-03 95/week @ 2022-05-10 23/week @ 2022-05-17 34/week @ 2022-05-24 52/week @ 2022-05-31 17/week @ 2022-06-07 5/week @ 2022-06-14 22/week @ 2022-06-21 15/week @ 2022-06-28 10/week @ 2022-07-05 25/week @ 2022-07-12 10/week @ 2022-07-19 20/week @ 2022-07-26 23/week @ 2022-08-02 13/week @ 2022-08-09

78 downloads per month

MIT license

18KB
325 lines

Legends of Runeterra - Deck Encoder/Decoder

Legends of Runeterra deck encoder/decoder in Rust. Port of LorDeckCodes.

Actions Status Crates.io MIT licensed

Documentation

API Documentation

Usage

To use lordeckcodes, add this to your Cargo.toml:

[dependencies]
lordeckcodes = "1"

Serde support

Serde support is optional and disabled by default. To enable use the feature serde.

[dependencies]
lordeckcodes = { version = "1", features = ["serde"] }

Examples

Obtain a deck from the provided code:

use lordeckcodes::encoder;

let deck = encoder::deck_from_code("CEBAEAIBAQTQMAIAAILSQLBNGUBACAIBFYDACAAHBEHR2IBLAEBACAIFAY");
assert!(deck.is_ok());

Generate a code from the provided deck:

use lordeckcodes::{encoder, CardCodeAndCount, Deck, LorError};
fn main() -> Result<(), LorError> {
    let deck: Deck = [
        ("01SI015", 3),
        ("01SI044", 3),
        ("01SI048", 3),
        ("01SI054", 3),
        ("01FR003", 3),
        ("01FR012", 3),
        ("01FR020", 3),
        ("01FR024", 3),
        ("01FR033", 3),
        ("01FR036", 3),
        ("01FR039", 3),
        ("01FR052", 3),
        ("01SI005", 2),
        ("01FR004", 2),
    ]
    .iter()
    .collect();
    let code = encoder::code_from_deck(&deck);
    assert!(code.is_ok());
    Ok(())
}

Dependencies

~0.5–1MB
~23K SLoC