[][src]Struct rscache::ItemLoader

pub struct ItemLoader {
    pub items: HashMap<u16, ItemDefinition>,
}

Caches all the item definitions that were loaded.

Fields

items: HashMap<u16, ItemDefinition>

Implementations

impl ItemLoader[src]

pub fn new(cache: &Cache) -> Result<Self, CacheError>[src]

Constructs a new ItemLoader.

It loads all the item definitions and caches them.

Errors

If this function encounters any errors it will be wrapped in a CacheError. (ReadErrors or I/O errors)

Examples

use rscache::ItemLoader;
 
let item_loader = ItemLoader::new(&cache)?;

pub fn load(&self, id: u16) -> Option<&ItemDefinition>[src]

Retrieves the ItemDefinition for the given item id.

Examples

// blue partyhat id = 1042
let blue_partyhat = item_loader.load(1042);
 
match blue_partyhat {
    Some(blue_partyhat) => {
        assert_eq!("Blue partyhat", blue_partyhat.name);
        assert_eq!(false, blue_partyhat.stackable);
        assert_eq!(false, blue_partyhat.members_only);
    },
    None => (),
}

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.