magnetease 0.1.3

A library to fetch magnets from the internet
Documentation
//! Magnetease is a library that fetches `Magnet`s from different sources.
//!
//! You can construct [Magnetease] with [Provider]s that you want to search.
//! Examples
//! ```
//! # tokio_test::block_on(async {
//! use magnetease::Magnetease;
//! let magnetease = Magnetease::new();
//! let magnets = magnetease.search("Ubuntu Pro").await;
//! # });
//! ```

mod magnetease;
/// Providers that you can search invidually or within [Magnetease]
pub mod providers;

use async_trait::async_trait;
pub use magnetease::Magnetease;
use reqwest::Client;
use thiserror::Error;

/// Holds the magnet itself in `url` and some metadata along with it.
#[derive(Clone, Debug)]
pub struct Magnet {
    /// The title associated with the magnet link.
    pub title: String,
    /// The URL of the magnet
    pub url: String,
    /// The number of seeders
    pub seeders: u32,
    /// The size of the content in bytes.
    pub bytes: u64,
}

#[derive(Error, Debug)]
pub enum MagneteaseError {
    #[error(transparent)]
    ConnectionError(#[from] reqwest::Error),
}

#[async_trait]
pub trait Provider {
    async fn search(&self, client: &Client, query: &str) -> Result<Vec<Magnet>, MagneteaseError>;
}