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

The rust crate does not work. #21

Closed
Maple0817 opened this issue Jun 27, 2023 · 7 comments · Fixed by #22
Closed

The rust crate does not work. #21

Maple0817 opened this issue Jun 27, 2023 · 7 comments · Fixed by #22

Comments

@Maple0817
Copy link

Maple0817 commented Jun 27, 2023

When I add it in toml, add use svgr_rs in rs; an error no external crate svgr_rs is happened.
Meanwhile, could you provide a sample code that how to use the crate in rust? seems the config is also not public.

@SyMind SyMind mentioned this issue Jun 28, 2023
@SyMind
Copy link
Collaborator

SyMind commented Jun 28, 2023

@Maple0817 I published a new one, please try it.

If you have other problem, must tell me!

@Maple0817
Copy link
Author

@SyMind , 2 things could imporve:

  1. return Result<String, Error> rather than Result<String, String>, since now transform function is directly used in rust.
  2. transform class to className since it is a jsx.

@SyMind
Copy link
Collaborator

SyMind commented Jun 29, 2023

transform class to className since it is a jsx.

@Maple0817 What does this mean? Can you explain it in detail.

@Maple0817
Copy link
Author

@SyMind this is a sample svg code, the class="icon" is not transformed. so one warning will happen:
Invalid DOM property class. Did you mean className?

@Maple0817
Copy link
Author

<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1684477297859" class="icon" viewBox="0 0 1053 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="33426" xmlns:xlink="http://www.w3.org/1999/xlink" width="32.90625" height="32"><path d="xxx" p-id="33429"></path></svg>

@SyMind
Copy link
Collaborator

SyMind commented Jun 29, 2023

@Maple0817 I fix second problem in #23.

But i have no idea to change String to Error, because i don't have much experience with the actual design for Rust library, what are the advantages of using Error?

Can you help make changes?

@Maple0817
Copy link
Author

Maple0817 commented Jun 30, 2023

@SyMind You can use thiserror crates.

It looks like
`#[derive(thiserror::Error, Debug)]

pub enum SvgrRsError {
#[error("********")]
Error1(string),
#[error("
")]
Error2(string),
}

pub fn fn1() -> Result<String, SvgrRsError> {
Err(SvgrRsError::Error2("********"))
}`

Since some functions should be changed include the napi, I am afraid would break other function.
So it will be better to change by you.

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

Successfully merging a pull request may close this issue.

2 participants