Struct factorio_mod_api::ModPortalClient
source · pub struct ModPortalClient { /* private fields */ }
Expand description
A simple caching client for the Factorio mod portal API.
Implementations
sourceimpl ModPortalClient
impl ModPortalClient
sourcepub fn new() -> Result<ModPortalClient>
pub fn new() -> Result<ModPortalClient>
Creates a new client with default configuration.
sourcepub fn with_client(client: Client) -> Result<ModPortalClient>
pub fn with_client(client: Client) -> Result<ModPortalClient>
Creates a new client with a pre-configured reqwest::Client
.
sourcepub async fn get_mod_spec(&self, name: &str) -> Result<&FullModSpec>
pub async fn get_mod_spec(&self, name: &str) -> Result<&FullModSpec>
Get the full spec of a Factorio mod. Request results are cached in memory.
Example
use factorio_mod_api::ModPortalClient;
use futures::TryFutureExt;
let client = ModPortalClient::new()?;
client.get_mod_spec("Warehousing")
.map_ok(|spec| println!("{}", spec.created_at));
Auto Trait Implementations
impl !RefUnwindSafe for ModPortalClient
impl Send for ModPortalClient
impl !Sync for ModPortalClient
impl Unpin for ModPortalClient
impl !UnwindSafe for ModPortalClient
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more