Struct trackermeta::ModInfo

source ·
pub struct ModInfo {
Show 14 fields pub id: u32, pub filename: String, pub title: String, pub size: String, pub md5: String, pub format: String, pub spotlit: bool, pub download_count: u32, pub fav_count: u32, pub scrape_time: String, pub channel_count: u32, pub genre: String, pub upload_date: String, pub instrument_text: String,
}
Expand description

Struct containing all of the info about a module

Fields§

§id: u32

The module ID of the module on modarchive

§filename: String

The filename of the module

§title: String

The title of the module

§size: String

The file size of the module, use the crate byte-unit to convert them to other units

§md5: String

The MD5 hash of the module file as a string

§format: String

The format of the module, for example XM, IT or MOD and more, basically the extension of the module file

§spotlit: bool

Spotlit module or not

§download_count: u32

Download count of the module at the time of scraping

§fav_count: u32

Times the module has been favourited at the time of scraping

§scrape_time: String

The time when it was scraped

§channel_count: u32

The channel count of the module

§genre: String

The genre of the module

§upload_date: String

The upload date of the module

§instrument_text: String

The instrument text of the module

Implementations§

source§

impl ModInfo

source

pub fn get(mod_id: u32) -> Result<ModInfo, Error>

Probably the singular most important function in this crate, takes a mod id (can be generated at random, deliberately entered or acquired by resolving a filename and picking a search result), and then gives you a full ModInfo struct.

Examples found in repository?
examples/as_struct_using_modid.rs (line 4)
3
4
5
6
fn main() {
    let modinfo = ModInfo::get(51772).unwrap();
    println!("{:#?}", modinfo);
}
More examples
Hide additional examples
examples/filename_to_id_to_modinfo.rs (line 5)
3
4
5
6
7
fn main() {
    let modid = ModInfo::resolve_filename("noway.s3m").unwrap()[0].id;
    let modinfo = ModInfo::get(modid).unwrap();
    println!("{:#?}", modinfo);
}
examples/filename_to_id_to_instrument_text.rs (line 5)
3
4
5
6
7
fn main() {
    let modid = ModInfo::resolve_filename("noway.s3m").unwrap()[0].id;
    let modtext = ModInfo::get(modid).unwrap();
    println!("{}", modtext.instrument_text);
}
examples/usual.rs (line 13)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
fn main() {
    let args: Vec<String> = std::env::args().collect();
    match args.get(1).unwrap_or(&"".into()).as_ref() {
        "get" => {
            let mod_id = ModInfo::resolve_filename(
                args.get(2)
                    .expect("No filename provided as second argument."),
            )
            .unwrap()[0]
                .id;
            let mod_info = ModInfo::get(mod_id).unwrap();
            println!("{}", &mod_info.instrument_text);

            println!("\n----------------------------------------\n");

            println!("{:#?}", mod_info);

            println!("\n----------------------------------------\n");

            println!("Download link: {}", mod_info.get_download_link());
        }
        _ => println!("Usage: trackermeta get <filename>"),
    }
}

Returns a modarchive download link for the given module, you can get this struct by using ModInfo::get(), or search using ModInfo::resolve_filename(), if you’re using the resolver function please consider using the ModSearch::get_download_link() method instead.

Examples found in repository?
examples/usual.rs (line 22)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
fn main() {
    let args: Vec<String> = std::env::args().collect();
    match args.get(1).unwrap_or(&"".into()).as_ref() {
        "get" => {
            let mod_id = ModInfo::resolve_filename(
                args.get(2)
                    .expect("No filename provided as second argument."),
            )
            .unwrap()[0]
                .id;
            let mod_info = ModInfo::get(mod_id).unwrap();
            println!("{}", &mod_info.instrument_text);

            println!("\n----------------------------------------\n");

            println!("{:#?}", mod_info);

            println!("\n----------------------------------------\n");

            println!("Download link: {}", mod_info.get_download_link());
        }
        _ => println!("Usage: trackermeta get <filename>"),
    }
}
source

pub fn resolve_filename(filename: &str) -> Result<Vec<ModSearch>, Error>

Searches for your string on Modarchive and returns the results on the first page (a.k.a only up to the first 40) as a vector of ModSearch

Examples found in repository?
examples/filename_to_id_to_modinfo.rs (line 4)
3
4
5
6
7
fn main() {
    let modid = ModInfo::resolve_filename("noway.s3m").unwrap()[0].id;
    let modinfo = ModInfo::get(modid).unwrap();
    println!("{:#?}", modinfo);
}
More examples
Hide additional examples
examples/filename_to_id_to_instrument_text.rs (line 4)
3
4
5
6
7
fn main() {
    let modid = ModInfo::resolve_filename("noway.s3m").unwrap()[0].id;
    let modtext = ModInfo::get(modid).unwrap();
    println!("{}", modtext.instrument_text);
}
examples/usual.rs (lines 7-10)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
fn main() {
    let args: Vec<String> = std::env::args().collect();
    match args.get(1).unwrap_or(&"".into()).as_ref() {
        "get" => {
            let mod_id = ModInfo::resolve_filename(
                args.get(2)
                    .expect("No filename provided as second argument."),
            )
            .unwrap()[0]
                .id;
            let mod_info = ModInfo::get(mod_id).unwrap();
            println!("{}", &mod_info.instrument_text);

            println!("\n----------------------------------------\n");

            println!("{:#?}", mod_info);

            println!("\n----------------------------------------\n");

            println!("Download link: {}", mod_info.get_download_link());
        }
        _ => println!("Usage: trackermeta get <filename>"),
    }
}

Trait Implementations§

source§

impl Debug for ModInfo

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.