//! Contains tons of structs used by the library pub(crate) type AuthFunc = fn(String) -> Result; // TODO: Figure out what the arguments should be for a search function and what it should return pub(crate) type SearchFunc = fn(String, Vec) -> Result; #[derive(Debug, Clone, PartialEq, Eq)] /// Specify the ServerInfo to be listed in for `/api?t=caps` /// /// These fields are just those listed in the example on [torznab.github.io](https://torznab.github.io), there's no actual specification for thse fields. /// TODO: Update this to have customizable fields instead pub struct ServerInfo { pub title: Option, pub email: Option, pub image: Option, pub version: Option, } #[derive(Debug, Clone, PartialEq, Eq)] /// The maximum and defaults for the `limit` parameter in queries /// `max` is the maximum number of results the program can return /// `default` is the default number of results the program will return pub struct Limits { /* I don't know why this would possibly need to be a u64, I can't imagine you'll be returning 18 quintillion results or whatever In fact, I *really* hope you aren't - if you are, you're doing something extremely wrong But hey, it's an option */ pub max: u64, pub default: u64, } #[derive(Debug, Clone, PartialEq, Eq)] /// A struct holding the info for a type of search /// - `search_type` must be `search`, `tv-search`, `movie-search`, `audio-search`, or `book-search` /// - `available` pub struct SearchInfo { pub search_type: String, pub available: bool, pub supported_params: Vec, } #[derive(Debug, Clone, PartialEq, Eq)] /// Contains subcategories, for use in `Category` pub struct Subcategory { pub id: String, pub name: String, } #[derive(Debug, Clone, PartialEq, Eq)] /// Contains a category, for use in `Caps` and searches as a query parameter pub struct Category { pub id: String, pub name: String, pub subcategories: Vec, } #[derive(Debug, Clone, PartialEq, Eq)] /// Contains a genre, for use in `Caps` and searches as a query parameter pub struct Genre { pub id: String, pub category_id: String, pub name: String, } #[derive(Debug, Clone, PartialEq, Eq)] /// Contains a tag, for use in `Caps` and searches as a query parameter pub struct Tag { pub id: String, pub category_id: String, pub name: String, } #[derive(Debug, Clone, PartialEq, Eq)] /// Holds the configuration for the capabilities of the Torznab server /// /// - server_info: `ServerInfo` /// - see: `ServerInfo` docs /// - limits: `Limits` /// - specifies the max and default items listed when searching /// - see: `Limits` docs /// - searching: `Vec` /// - specifies the capabilities of each search mode /// - see: `SearchInfo` docs /// - categories: `Vec` /// - lists known categories /// - see: `Category` docs /// - genres: `Option>` /// - lists known genres, optional /// - see: `Genre` docs /// ///
Note that this library might not support all the capabilities listed in yet, so check the README before listing capabilities, or just accept that unsupported capabilities will return error 404. /// /// It's recommended to add any capabilities you want, and set `available` to `false` in the `Caps` struct for any currently unsupported search types.
/// /// /// TODO: Add a way to partially(?) generate automatically from the Config pub struct Caps { pub server_info: ServerInfo, pub limits: Limits, pub searching: Vec, pub categories: Vec, pub genres: Option>, pub tags: Option>, } #[derive(Debug, Clone, PartialEq, Eq)] /// A struct that holds configuration for torznab-toolkit /// A search function (/api?t=search) and capabilities (/api?t=caps - struct Caps) required /// Everything else is optional pub struct Config { pub search: SearchFunc, // NOTE: This is NOT optional, pub auth: Option, pub caps: Caps, pub tvsearch: Option, pub movie: Option, pub music: Option, pub book: Option, }