BaldDemian opened a new issue, #3755:
URL: https://github.com/apache/fory/issues/3755

   ### Question
   
   ## Status Quo
   The current Rust documentation suggests that users only need to depend on 
`fory` in `Cargo.toml`. Consider this example:
   
   
https://github.com/apache/fory/blob/0e4ac5917898e4fbd253a5d638a21ff15d500d67/docs/guide/rust/index.md?plain=1#L45-L91
   
   If the user does not include `fory-core` as a dependency in `Cargo.toml`, 
the example code won't compile: 
   
   <img width="1047" height="211" alt="Image" 
src="https://github.com/user-attachments/assets/5a5502d0-9199-4324-af51-05985824d8b5";
 />
   
   The reason is that although `fory` uses `fory-core` and `fory-derive`:
   
   
https://github.com/apache/fory/blob/0e4ac5917898e4fbd253a5d638a21ff15d500d67/rust/fory/src/lib.rs#L1215-L1221
   
   the code generated by proc macro is still resolved in the user's crate. 
`ForyStruct` macro expands to `::fory_core::...` paths like this:
   
   
https://github.com/apache/fory/blob/0e4ac5917898e4fbd253a5d638a21ff15d500d67/rust/fory-derive/src/object/serializer.rs#L152-L153
   
   
   Rust dependency resolution does not automatically give the user's crate an 
extern crate named `fory-core` just because `fory` depends on `fory-core`. 
User's crate can use  `fory::Fory` or `fory::Serializer` but cannot use 
`::fory_core::...` 
   
   Therefore, users currently have to explicitly add `fory-core` as a 
dependency. 
   
   Note: the above problem is NOT introduced by the absolute path refactor in 
https://github.com/apache/fory/pull/3666 and can be reproduced in its parent 
commit.
   
   ## Question
   
   Should we let Rust users include `fory-core` as a depenency together with 
`fory`? 
   
   If yes, we may better document this so it is more helpful to the user;
   if no, a possible fix would be changing the macro derived code from 
`::fory_core::Serializer` to `::fory::Serializer` and making sure `fory` pub 
use `fory_core::Serializer`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to