unity-release-client/README.md
2024-10-06 23:14:08 -05:00

2 KiB

Unity Release API Client

This library makes it easier to interact with Unity's Release API for querying information about available Unity editor versions.

Usage

let client = UnityReleaseClient::default();
let response: Result<OffsetConnection, Error> = client
    .request()
    .with_order(Order::Ascending) // order by ascending release date
    .with_limit(5) // 5 results per query
    .with_offset(20) // offset by 20 results
    .with_stream(Stream::LTS) // filter for only LTS versions
    .with_platform(Platform::Linux) // filter for only Linux releases
    .with_architecture(Architecture::Arm64) // filter for only ARM64 support
    .with_version("2020.3.44f1".to_string()) // filter for version 2020.3.44f1
    .send()
    .await?;

Documentation

To use the client, create a UnityReleaseClient by using Default::default or UnityReleaseClient::new(client) where client is a reqwuest::Client.

let client = UnityReleaseClient::default();
// with a custom client
let client = reqwest::Client::default();
let unity_client = UnityReleaseClient::new(client);

To prepare a request, get a new RequestBuilder and configure the parameters.

let request_builder = client.request().with_limit(10);

In order to send the request, either build the Request or call RequestBuilder::send

let request: Request = request_builder.into();
let response = request.send();
let response = request_builder.send(); // build and send in the same step

The response is a Result<OffsetConnection, Error> and the schema is defined by Unity's OpenAPI spec available from the API documentation. It's also possible to look through response.rs.