pub struct Client { /* private fields */ }Expand description
Client for X-Plane Local Web API
OpenAPI model for the documented X-Plane local REST Web API using the latest
versioned REST paths (/api/v3/...) plus the unversioned capabilities endpoint.
Version: 3.0
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(baseurl: &str) -> Self
pub fn new(baseurl: &str) -> Self
Create a new client.
baseurl is the base URL provided to the internal
reqwest::Client, and should include a scheme and hostname,
as well as port and a path stem if applicable.
Sourcepub fn new_with_client(baseurl: &str, client: Client) -> Self
pub fn new_with_client(baseurl: &str, client: Client) -> Self
Construct a new client with an existing reqwest::Client,
allowing more control over its configuration.
baseurl is the base URL provided to the internal
reqwest::Client, and should include a scheme and hostname,
as well as port and a path stem if applicable.
Source§impl Client
impl Client
Sourcepub async fn get_capabilities<'a>(
&'a self,
) -> Result<ResponseValue<CapabilitiesResponse>, Error<ApiError>>
pub async fn get_capabilities<'a>( &'a self, ) -> Result<ResponseValue<CapabilitiesResponse>, Error<ApiError>>
Get API capabilities and simulator version
Returns the supported API versions and the running X-Plane version. This endpoint is intentionally unversioned (/api/capabilities).
Sends a GET request to /api/capabilities
Sourcepub async fn list_datarefs<'a>(
&'a self,
fields: Option<&'a str>,
filter_name: Option<&'a Vec<String>>,
limit: Option<NonZeroU64>,
start: Option<i64>,
) -> Result<ResponseValue<DatarefListResponse>, Error<ApiError>>
pub async fn list_datarefs<'a>( &'a self, fields: Option<&'a str>, filter_name: Option<&'a Vec<String>>, limit: Option<NonZeroU64>, start: Option<i64>, ) -> Result<ResponseValue<DatarefListResponse>, Error<ApiError>>
List datarefs
Returns datarefs currently registered in the running simulator, including built-in and third-party datarefs.
Sends a GET request to /api/v3/datarefs
Arguments:
-
fields: Comma-separated field names to return for each record, orall(default). -
filter_name: Repeatable exact-match filter by dataref name. -
limit: Maximum number of records to return for pagination. -
start: Inclusive start index for pagination.
Sourcepub async fn get_dataref_count<'a>(
&'a self,
) -> Result<ResponseValue<CountResponse>, Error<()>>
pub async fn get_dataref_count<'a>( &'a self, ) -> Result<ResponseValue<CountResponse>, Error<()>>
Get dataref count
Returns the current number of registered datarefs in the running simulator.
Sends a GET request to /api/v3/datarefs/count
Sourcepub async fn get_dataref_value<'a>(
&'a self,
id: i64,
index: Option<i64>,
) -> Result<ResponseValue<DatarefValueResponse>, Error<ApiError>>
pub async fn get_dataref_value<'a>( &'a self, id: i64, index: Option<i64>, ) -> Result<ResponseValue<DatarefValueResponse>, Error<ApiError>>
Get a dataref value
Returns the current value of a dataref, or a single element when an array index is provided.
Sends a GET request to /api/v3/datarefs/{id}/value
Arguments:
id: Dataref session ID.index: Optional array index to read from array datarefs.
Sourcepub async fn set_dataref_value<'a>(
&'a self,
id: i64,
index: Option<i64>,
body: &'a DatarefValueWriteRequest,
) -> Result<ResponseValue<()>, Error<ApiError>>
pub async fn set_dataref_value<'a>( &'a self, id: i64, index: Option<i64>, body: &'a DatarefValueWriteRequest, ) -> Result<ResponseValue<()>, Error<ApiError>>
Set a dataref value
Sets a dataref value. For array datarefs, callers can update one index or provide values for the full array.
Sends a PATCH request to /api/v3/datarefs/{id}/value
Arguments:
id: Dataref session ID.index: Optional array index to update on array datarefs.body: JSON payload containingdataas a scalar value, full array value, or base64 string for binary datarefs.
Sourcepub async fn list_commands<'a>(
&'a self,
fields: Option<&'a str>,
filter_name: Option<&'a Vec<String>>,
limit: Option<NonZeroU64>,
start: Option<i64>,
) -> Result<ResponseValue<CommandListResponse>, Error<ApiError>>
pub async fn list_commands<'a>( &'a self, fields: Option<&'a str>, filter_name: Option<&'a Vec<String>>, limit: Option<NonZeroU64>, start: Option<i64>, ) -> Result<ResponseValue<CommandListResponse>, Error<ApiError>>
List commands
Returns commands currently registered in the running simulator, including built-in and third-party commands.
Sends a GET request to /api/v3/commands
Arguments:
-
fields: Comma-separated field names to return for each record, orall(default). -
filter_name: Repeatable exact-match filter by command name. -
limit: Maximum number of records to return for pagination. -
start: Inclusive start index for pagination.
Sourcepub async fn get_command_count<'a>(
&'a self,
) -> Result<ResponseValue<CountResponse>, Error<()>>
pub async fn get_command_count<'a>( &'a self, ) -> Result<ResponseValue<CountResponse>, Error<()>>
Get command count
Returns the current number of registered commands in the running simulator.
Sends a GET request to /api/v3/commands/count
Sourcepub async fn activate_command<'a>(
&'a self,
id: i64,
body: &'a ActivateCommandRequest,
) -> Result<ResponseValue<()>, Error<ApiError>>
pub async fn activate_command<'a>( &'a self, id: i64, body: &'a ActivateCommandRequest, ) -> Result<ResponseValue<()>, Error<ApiError>>
Activate a command for a fixed duration
Triggers a command for a fixed duration in seconds. A duration of 0 behaves like immediate press-and-release.
Sends a POST request to /api/v3/command/{id}/activate
Arguments:
id: Command session ID.body: JSON payload containing requireddurationin seconds. Maximum allowed duration is 10 seconds.
Sourcepub async fn start_flight<'a>(
&'a self,
body: &'a FlightRequest,
) -> Result<ResponseValue<()>, Error<ApiError>>
pub async fn start_flight<'a>( &'a self, body: &'a FlightRequest, ) -> Result<ResponseValue<()>, Error<ApiError>>
Start a new flight
Starts a new flight using a complete flight initialization payload.
Sends a POST request to /api/v3/flight
Arguments:
body: Full flight initialization object compatible with X-Plane’s Flight Initialization API schema.
Sourcepub async fn update_flight<'a>(
&'a self,
body: &'a FlightRequest,
) -> Result<ResponseValue<()>, Error<ApiError>>
pub async fn update_flight<'a>( &'a self, body: &'a FlightRequest, ) -> Result<ResponseValue<()>, Error<ApiError>>
Update the current flight
Updates the active flight using a complete or partial flight initialization payload.
Sends a PATCH request to /api/v3/flight
Arguments:
body: Partial or full flight initialization object. Start location and aircraft are not changeable during update.