Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Url (rust crate) support #83

Closed
tonymushah opened this issue May 29, 2023 · 1 comment
Closed

Adding Url (rust crate) support #83

tonymushah opened this issue May 29, 2023 · 1 comment

Comments

@tonymushah
Copy link
Contributor

It would be nice and convinient for building reqwest based API

@tonymushah
Copy link
Contributor Author

tonymushah commented May 30, 2023

Okay, i already found my own solution for this.
specta already support url. (in some way)

My problem is that :

  • I have this struct
use url::Url;
use specta::Type;

#[derive(Type)]
pub struct BsxTitleData { 
    pub title: String,
    pub url: Url,
    pub image: Url,
    pub rating: f64,
}

I can't compile because url::Url doesn't implement the Type trait from specta

I tried to implement to my own code but it didn't work 😒.

But i found the solution, that solve partially the problem.

Add a #[specta(type = String)] on those fields that has the url::Url type

so the struct above should be like this:

use url::Url;
use specta::Type;

#[derive(Type)]
pub struct BsxTitleData { 
    pub title: String,
    #[specta(type = String)]
    pub url: Url,
    #[specta(type = String)]
    pub image: Url,
    pub rating: f64,
}

Note : It seems to compile and export very well to typescript but i'm not sure if it works with tauri.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant