uvm_live_platform/
lib.rs

1pub mod error;
2mod model;
3pub use model::*;
4mod api;
5
6use crate::error::ErrorRepr;
7pub use api::fetch_release::FetchRelease;
8pub use api::list_versions::ListVersions;
9use unity_version::Version;
10
11pub type Result<T> = std::result::Result<T, error::LivePlatformError>;
12
13pub fn versions() -> Result<impl Iterator<Item = String>> {
14    _list_all_versions(false, false)
15}
16
17pub fn all_versions() -> Result<impl Iterator<Item = String>> {
18    _list_all_versions(false, true)
19}
20
21pub fn all_versions_with_revision() -> Result<impl Iterator<Item = String>> {
22    _list_all_versions(true, true)
23}
24
25fn _list_all_versions(include_revisions: bool, auto_page: bool) -> Result<ListVersions> {
26    Ok(ListVersions::builder()
27        .include_revision(include_revisions)
28        .with_u7_alpha()
29        .with_extended_lts()
30        .with_system_architecture()
31        .with_current_platform()
32        .autopage(auto_page)
33        .list()
34        .map_err(ErrorRepr::ListVersionsError)?)
35}
36
37pub fn fetch_release<V: Into<Version>>(version: V) -> Result<Release> {
38    let r = FetchRelease::builder(version)
39        .with_current_platform()
40        .with_system_architecture()
41        .with_extended_lts()
42        .with_u7_alpha()
43        .fetch()
44        .map_err(ErrorRepr::FetchReleaseError)?;
45    Ok(r)
46}
47
48#[cfg(test)]
49mod tests {
50    use super::*;
51
52    #[test]
53    fn it_works() {
54        let result: Vec<String> = all_versions().unwrap().collect();
55        println!("{:?}", result)
56    }
57}