pub struct Root {
pub projects: Vec<String>,
}Expand description
Everything start from here.
A root is a json response from papermc’s official ci. It contains different projects, sach as paper, velocity, etc.
You can easily read these project name(or project_id),
then use Self::get_project to get further.
Fields§
§projects: Vec<String>a list contains all supported projects’ name(or project_id)
Implementations§
Source§impl Root
impl Root
Sourcepub async fn new() -> Result<Self>
pub async fn new() -> Result<Self>
Request the url then parse the response into Root
Examples found in repository?
examples/fetch_papermc.rs (line 9)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
pub async fn main()-> Result<()>{
let download_path = "/tmp/target.jar";
let root = Root::new().await?;
let paper = root.get_project("paper").await?;
let latest_version= paper.get_latest_version().await?;
let app = latest_version.get_latest_build().await?;
app.download(download_path).await?;
assert!(app.checksum(download_path).await?);
let download_path_1165 = "/tmp/target-1165.jar";
let version_1165= paper.get_version("1.16.5").await?;
let app_1165= version_1165.get_latest_build().await?;
app_1165.download(download_path_1165).await?;
assert!(app_1165.checksum(download_path_1165).await?);
Ok(())
}Sourcepub async fn get_project(&self, project: &str) -> Result<Project>
pub async fn get_project(&self, project: &str) -> Result<Project>
Return the given project’s info.
Examples found in repository?
examples/fetch_papermc.rs (line 11)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
pub async fn main()-> Result<()>{
let download_path = "/tmp/target.jar";
let root = Root::new().await?;
let paper = root.get_project("paper").await?;
let latest_version= paper.get_latest_version().await?;
let app = latest_version.get_latest_build().await?;
app.download(download_path).await?;
assert!(app.checksum(download_path).await?);
let download_path_1165 = "/tmp/target-1165.jar";
let version_1165= paper.get_version("1.16.5").await?;
let app_1165= version_1165.get_latest_build().await?;
app_1165.download(download_path_1165).await?;
assert!(app_1165.checksum(download_path_1165).await?);
Ok(())
}Trait Implementations§
Source§impl<'de> Deserialize<'de> for Root
impl<'de> Deserialize<'de> for Root
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Root
impl RefUnwindSafe for Root
impl Send for Root
impl Sync for Root
impl Unpin for Root
impl UnwindSafe for Root
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more