Skip to content

Commit

Permalink
Make Ubi struct implement Send and Sync again
Browse files Browse the repository at this point in the history
I did this for backwards compatibility.
  • Loading branch information
autarch committed Dec 26, 2024
1 parent 3dd0d22 commit 7be5bf3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion ubi/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,11 @@ impl<'a> UbiBuilder<'a> {
))
}

fn new_forge(&self, project_name: String, forge_type: &ForgeType) -> Result<Box<dyn Forge>> {
fn new_forge(
&self,
project_name: String,
forge_type: &ForgeType,
) -> Result<Box<dyn Forge + Send + Sync>> {
let api_base = self.api_base_url.map(Url::parse).transpose()?;
Ok(match forge_type {
ForgeType::GitHub => Box::new(GitHub::new(
Expand Down
3 changes: 3 additions & 0 deletions ubi/src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ pub(crate) struct GitHub {
token: Option<String>,
}

unsafe impl Send for GitHub {}
unsafe impl Sync for GitHub {}

#[derive(Debug, Deserialize, Serialize)]
pub(crate) struct Release {
pub(crate) assets: Vec<Asset>,
Expand Down
3 changes: 3 additions & 0 deletions ubi/src/gitlab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ pub(crate) struct GitLab {
token: Option<String>,
}

unsafe impl Send for GitLab {}
unsafe impl Sync for GitLab {}

#[derive(Debug, Deserialize, Serialize)]
struct Release {
assets: GitLabAssets,
Expand Down
4 changes: 2 additions & 2 deletions ubi/src/ubi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use url::Url;
/// [`UbiBuilder`](crate::UbiBuilder) struct to create a new `Ubi` instance.
#[derive(Debug)]
pub struct Ubi<'a> {
forge: Box<dyn Forge>,
forge: Box<dyn Forge + Send + Sync>,
asset_url: Option<Url>,
asset_picker: AssetPicker<'a>,
installer: Installer,
Expand All @@ -38,7 +38,7 @@ pub(crate) struct Download {
impl<'a> Ubi<'a> {
/// Create a new Ubi instance.
pub(crate) fn new(
forge: Box<dyn Forge>,
forge: Box<dyn Forge + Send + Sync>,
asset_url: Option<Url>,
asset_picker: AssetPicker<'a>,
installer: Installer,
Expand Down

0 comments on commit 7be5bf3

Please sign in to comment.