Struct LcuClient

Source
pub struct LcuClient { /* private fields */ }
Expand description

Struct representing a connection to the LCU

Implementations§

Source§

impl LcuClient

Source

pub async fn batched<'a, R>( &self, requests: &[Request<'a>], buffer_size: usize, request_client: &RequestClient, ) -> Vec<Result<Option<R>, Error>>

System for batching requests to the LCU by sending a slice The buffer size is how many requests can be operated on at the same time, returns a vector with all the replies

§Errors

The value will be an error if the provided type is invalid, or the LCU API is not running

Source§

impl LcuClient

Source

pub fn new(force_lock_file: bool) -> Result<Self, Error>

Attempts to create a connection to the LCU, errors if it fails to spin up the child process, or fails to get data from the client.

force_lock_file will read the lock file regardless of whether the client or the game is running at the time

§Errors

This will return an error if the LCU API is not running, this can include the client being down, the lock file being unable to be opened, or the LCU not running at all

Source

pub fn new_with_credentials(auth: &str, port: u16) -> LcuClient

Creates a new LCU Client that implicitly trusts the port and auth string given, Encoding them in a URL and header respectively

Source

pub fn reconnect(&mut self, force_lock_file: bool) -> Result<(), Error>

Queries the client or lock file, getting a new url and auth header

§Errors

This will return an error if the lock file is inaccessible, or if the LCU is not running

Source

pub fn reconnect_with_credentials(&mut self, auth: &str, port: u16)

Sets the url and auth header according to the auth and port provided

Source

pub fn url(&self) -> &str

Returns a reference to the URL in use

Source

pub fn auth_header(&self) -> &str

Returns a reference to the auth header in use

Source

pub async fn delete<R: DeserializeOwned>( &self, endpoint: impl AsRef<str>, request_client: &RequestClient, ) -> Result<Option<R>, Error>

Sends a delete request to the LCU

§Errors

This will return an error if the LCU API is not running, or the provided type is invalid

Source

pub async fn get<R: DeserializeOwned>( &self, endpoint: impl AsRef<str>, request_client: &RequestClient, ) -> Result<Option<R>, Error>

Sends a get request to the LCU

let request_client = irelia::RequestClient::new();
let lcu_client = irelia::rest::LcuClient::new(false)?;

 let response: Option<serde_json::Value> = lcu_client.get("/example/endpoint/", &request_client)?;
§Errors

This will return an error if the LCU API is not running, or the provided type is invalid

Source

pub async fn head<S>( &self, endpoint: impl AsRef<str>, request_client: &RequestClient, ) -> Result<Response<Incoming>, Error>

Sends a head request to the LCU

§Errors

This will return an error if the LCU API is not running

Source

pub async fn patch<T, R>( &self, endpoint: impl AsRef<str>, body: Option<T>, request_client: &RequestClient, ) -> Result<Option<R>, Error>

Sends a patch request to the LCU

§Errors

This will return an error if the LCU API is not running, or the provided type or body is invalid

Source

pub async fn post<T, R>( &self, endpoint: impl AsRef<str>, body: Option<T>, request_client: &RequestClient, ) -> Result<Option<R>, Error>

Sends a post request to the LCU

§Errors

This will return an error if the LCU API is not running, or the provided type or body is invalid

Source

pub async fn put<T, R>( &self, endpoint: impl AsRef<str>, body: Option<T>, request_client: &RequestClient, ) -> Result<Option<R>, Error>

Sends a put request to the LCU

§Errors

This will return an error if the LCU API is not running, or the provided type or body is invalid

Source

pub async fn schema(remote: &'static str) -> Result<Schema, Error>

Fetches the schema from a remote endpoint, for example: <https://raw.githubusercontent.com/dysolix/hasagi-types/main/swagger.json/>

§Errors

This function will error if it fails to connect to the given remote, or if the given remote cannot be deserialized to match the Schema type

Source

pub async fn lcu_request<T: Serialize, R: DeserializeOwned>( &self, endpoint: &str, method: &str, body: Option<T>, request_client: &RequestClient, ) -> Result<Option<R>, Error>

Makes a request to the LCU with an unspecified method, valid options being “PUT”, “GET”, “POST”, “HEAD”, “DELETE”

§Errors

This will return an error if the LCU API is not running, or the provided type or body is invalid

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

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

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more