Giter VIP home page Giter VIP logo

Comments (10)

dwrensha avatar dwrensha commented on June 20, 2024 3

To use the new feature, you need to import rust.capnp. Probably the easiest way to do that is to copy it and include it among your own schema files.

To indicate that you will include the generated code under the module foo::bar::baz, you would
add a file-level annotation $Rust.parentModule("foo::bar::baz").

from capnproto-rust.

mashedcode avatar mashedcode commented on June 20, 2024 1

As mentioned in #107, a possible but breaking change that would solve this issue might look like this broken link.

Discussion on this is a little bit scattered so I'll quote @dwrensha's links to related issues again:
capnproto/capnpc-rust#5
capnproto/capnpc-rust#30

I don't use the annotation stuff from capnproto/capnpc-rust#30 so I don't know how exactly it's related and fits or would even solve this issue. Some more explanation would be great.

I think we need to add an annotation to tell capnpc-rust the module path that the generated code will be included as, where "::" is the default. This would be similar to how the C++ plugin lets you specify a namespace.

@dwrensha So, the idea is to specify a namespace on top of each schema file to invoke non-default behavior?

Other than that I don't see anyone mentioning an approach to solve this issue.

More discussion on this that gets us somewhere would be appreciated!

Update: I'm not interested in this anymore.

from capnproto-rust.

dwrensha avatar dwrensha commented on June 20, 2024 1

Fixed in 57ab346.

from capnproto-rust.

gibsond avatar gibsond commented on June 20, 2024 1

Thank-you!

from capnproto-rust.

dwrensha avatar dwrensha commented on June 20, 2024

Yep, the generated code assumes that you add it as a module at the top level of the crate.

A shortcut to get the local file's scope wouldn't solve the general case, where we might have multiple schemas that refer to each other.

To support non-top-level generated modules, I think we need to add an annotation to tell capnpc-rust the module path that the generated code will be included as, where "::" is the default. This would be similar to how the C++ plugin lets you specify a namespace.

PS. Whoa, I didn't know about the #[path = ...] attribute. That seems useful, though it's too bad I can't make the path depend on a compile-time environment variable, e.g. #[path= concat!(env!("OUT_DIR"), "/test_capnp.rs")], which would be perfect for Cargo integration.

from capnproto-rust.

futile avatar futile commented on June 20, 2024

Also running into this issue, currently hotfixing it by replacing all ::<top_level_name> with super.

from capnproto-rust.

dwrensha avatar dwrensha commented on June 20, 2024

This is mainly a code generation issue, so I'm closing in favor of this issue in capnpc-rust: capnproto/capnpc-rust#5

from capnproto-rust.

dwrensha avatar dwrensha commented on June 20, 2024

Reopening here, as capnpc-rust has been moved back into this repo.

from capnproto-rust.

gibsond avatar gibsond commented on June 20, 2024

I am having a problem with this now. In trying to see what the solution is, my search led me to capnproto/capnpc-rust#5 first, than this one, and from here capnproto/capnpc-rust#30.

It seems that #5 was closed because #16 was open, and #16 was closed because of #5. Glad it has been re-opened as of August 30, 2018.

I can get mine to complie if I change the generated code with instances of, for example, ::foo_capnp::first_msg::second_msg to self::second_msg.

This is using edition = "2018" in the toml file.

I hope we can find a fix for this situation of using capnp List.

Thanks.

from capnproto-rust.

olanod avatar olanod commented on June 20, 2024

I'm also doing the replace hack ::{file}_capnp::{msg}::{sub_msg} -> self::{sub_msg}. What would take to use self, super, crate and favor relative paths instead of absolute ones?

from capnproto-rust.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.