fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.

Home Page:https://fzyzcjy.github.io/flutter_rust_bridge/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

private field in external lib should mirror?

sealter opened this issue · comments

Sorry ask this stupid question, but I really don't know the answer.

I found the doc or example about struct mirror in external lib is all pub.

for example, I use PathBuf and reqwest::Client in my api struct and method (I reuse reqwest client for request, I wrapper it in my own struct, so I don't create it twice or more). I need mirror the struct, they all have private field, should I mirror them, or just the pub field?

Thank you.

I need mirror the struct, they all have private field, should I mirror them, or just the pub field?

If you want to use 3rd party types but do not need to access its field (I guess your case is like that), then just use the auto rust opaque feature. In other words, no need to do anything at all (no mirror etc), and it will be auto wrapped opaquely.

Oh, I see, I use builder pattern and make 3rd as param in pub build method. I modify the code remove it in param and it's OK now.

But I still want to know if it should mirror private field, if I can't modify the code, just like this case make it as param or return value of method or function, maybe others have the same doubt.

Thank you and thank you for your work, It's exellent.

You are welcome!

But I still want to know if it should mirror private field

I guess you will face errors no matter whether mirror it or ignore it, because the struct will not be able to be constructed directly.

OK, Thanks. I will close this issue.

Thank you very much.

You are welcome!

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.