sponsor_block/
lib.rs

1//! A Rust wrapper for the SponsorBlock API.
2//!
3//! ## Usage
4//! Simply add it to your `Cargo.toml` as you would any other crate.
5//!
6//! ### Features
7//! Default features:
8//! - `private_searches`: This enables the use of private [hash-based segment searching](https://wiki.sponsor.ajay.app/w/API_Docs#GET_.2Fapi.2FskipSegments.2F:sha256HashPrefix),
9//!   which significantly improves privacy at a slight bandwidth and performance
10//!   cost.
11//!
12//!   You should almost certainly leave this on.
13//! - `user`: The standard set of user functions.
14//!
15//! Optional features:
16//! - `vip`: The set of functions for only VIP users.
17//! - `gen_user_id`: A utility function for generating local user IDs for use
18//!   with the service.
19//!
20//!   *Do not* use this every time you start up a client - prefer using a single
21//!   saved ID for the same 'user'. This is for cases where you may want to
22//!   generate new user IDs for users of your application, giving each user
23//!   their own ID.
24//!
25//! ## Example
26//! The following is a short example of how you might fetch the segments for a
27//! video:
28//!
29//! ```rust,no_run
30//! use sponsor_block::{AcceptedCategories, Client};
31//!
32//! // This should be random, treated like a password, and stored across sessions
33//! const USER_ID: &str = "your local user id";
34//!
35//! let client = Client::new(USER_ID);
36//! let video_segments = client
37//!     .fetch_segments("9Yhc6mmdJC4", AcceptedCategories::all())
38//!     .await
39//!     .ok();
40//!
41//! // Then do something with your video segments...
42//! ```
43
44// Linting rules
45#![warn(
46	clippy::complexity,
47	clippy::correctness,
48	clippy::dbg_macro,
49	clippy::perf,
50	clippy::style,
51	clippy::suspicious,
52	clippy::pedantic,
53	clippy::filetype_is_file,
54	clippy::str_to_string,
55	missing_docs,
56	rustdoc::missing_crate_level_docs
57)]
58#![allow(
59	clippy::cast_possible_truncation,
60	clippy::cast_possible_wrap,
61	clippy::cast_precision_loss,
62	clippy::cast_sign_loss,
63	clippy::doc_markdown,
64	clippy::module_name_repetitions,
65	clippy::similar_names,
66	clippy::too_many_lines,
67	clippy::unnecessary_wraps,
68	dead_code,
69	unused_macros
70)]
71
72// Modules
73mod api;
74mod client;
75mod error;
76#[cfg(feature = "gen_user_id")]
77mod gen_user_id;
78mod segment;
79mod util;
80
81// Public Exports
82#[cfg(feature = "gen_user_id")]
83pub use self::gen_user_id::*;
84pub use self::{client::*, error::*, segment::*};