Rust Language Binding #110

Open
opened 2025-12-30 01:20:55 +01:00 by adam · 16 comments
Owner

Originally created by @Sir-NoChill on GitHub (Mar 8, 2024).

I'm looking to contribute a rust language binding for PKL, I was wondering if anyone had already started on one after finding this discussion.

Originally created by @Sir-NoChill on GitHub (Mar 8, 2024). I'm looking to contribute a rust language binding for PKL, I was wondering if anyone had already started on one after finding [this discussion](https://github.com/apple/pkl/discussions/49).
Author
Owner

@Sir-NoChill commented on GitHub (Mar 10, 2024):

Current repository. I'm essentially duplicating the pkl-go repository and translating to rust.

@Sir-NoChill commented on GitHub (Mar 10, 2024): Current [repository](https://github.com/Sir-NoChill/pkl-rust). I'm essentially duplicating the [pkl-go](https://github.com/apple/pkl-go) repository and translating to rust.
Author
Owner

@stackoverflow commented on GitHub (Mar 11, 2024):

Inded pkl-go is a good example for you to base your implementation on.
Also, take a look here for the message passing specification.

@stackoverflow commented on GitHub (Mar 11, 2024): Inded pkl-go is a good example for you to base your implementation on. Also, take a look [here](https://pkl-lang.org/main/current/bindings-specification/index.html) for the message passing specification.
Author
Owner

@mmbarness commented on GitHub (Mar 11, 2024):

Interested in contributing. I'll take a look.

@mmbarness commented on GitHub (Mar 11, 2024): Interested in contributing. I'll take a look.
Author
Owner

@holzensp commented on GitHub (Mar 12, 2024):

As far as I know @jackkleeman was looking at this also, but I don't know whether he made a start anywhere.

@holzensp commented on GitHub (Mar 12, 2024): As far as I know @jackkleeman was looking at this also, but I don't know whether he made a start anywhere.
Author
Owner

@jackkleeman commented on GitHub (Mar 12, 2024):

Go for it - not started anything. Translating the go repo is a solid strategy

@jackkleeman commented on GitHub (Mar 12, 2024): Go for it - not started anything. Translating the go repo is a solid strategy
Author
Owner

@Sir-NoChill commented on GitHub (Mar 15, 2024):

Do we need to encode the field names in the message passing standard? I am assuming yes, since it would be hard for pkl to guess positional arguments in something like

[
  0x20,
  {
    "file:",
    true,
    true,
  }
]

For context, I'm attempting to use the rmp_serde package to serialize the messages, but I'm not sure how to force it to encode field names, so if anyone has any ideas or experience that would be mighty helpful.

@Sir-NoChill commented on GitHub (Mar 15, 2024): Do we need to encode the field names in the message passing standard? I am assuming yes, since it would be hard for pkl to guess positional arguments in something like ``` [ 0x20, { "file:", true, true, } ] ``` For context, I'm attempting to use the [rmp_serde](https://docs.rs/rmp-serde/latest/rmp_serde/) package to serialize the messages, but I'm not sure how to force it to encode field names, so if anyone has any ideas or experience that would be mighty helpful.
Author
Owner

@jackkleeman commented on GitHub (Mar 15, 2024):

https://pkl-lang.org/main/current/bindings-specification/index.html might be some info here?

@jackkleeman commented on GitHub (Mar 15, 2024): https://pkl-lang.org/main/current/bindings-specification/index.html might be some info here?
Author
Owner

@Sir-NoChill commented on GitHub (Mar 15, 2024):

That's the page that prompts my question, I'm going to assume messages need to be formatted more or less exactly the same as what's shown unless there is evidence to suggest otherwise.

@Sir-NoChill commented on GitHub (Mar 15, 2024): That's the page that prompts my question, I'm going to assume messages need to be formatted more or less exactly the same as what's shown unless there is evidence to suggest otherwise.
Author
Owner

@Sir-NoChill commented on GitHub (Mar 15, 2024):

Including for posterity sake that I managed to figure it out. See the corresponding issue in my repo.

@Sir-NoChill commented on GitHub (Mar 15, 2024): Including for posterity sake that I managed to figure it out. See the [corresponding issue](https://github.com/Sir-NoChill/pkl-rust/issues/3) in my repo.
Author
Owner

@Sir-NoChill commented on GitHub (May 7, 2024):

Does anyone know if there is a way to get the pkl server to read input from a fifo or some other method of IPC? I'm trying to debug my communications between the rust program and the server and am having some difficulties.

@Sir-NoChill commented on GitHub (May 7, 2024): Does anyone know if there is a way to get the `pkl server` to read input from a fifo or some other method of IPC? I'm trying to debug my communications between the rust program and the server and am having some difficulties.
Author
Owner

@jackkleeman commented on GitHub (May 7, 2024):

I think it just reads stdin, but you should be able to exec the process using any file as stdin, including a fifo?

@jackkleeman commented on GitHub (May 7, 2024): I think it just reads stdin, but you should be able to exec the process using any file as stdin, including a fifo?
Author
Owner

@z-jxy commented on GitHub (Jun 13, 2024):

If any references are still needed for this, I have a rust binding https://github.com/z-jxy/rpkl

@z-jxy commented on GitHub (Jun 13, 2024): If any references are still needed for this, I have a rust binding [https://github.com/z-jxy/rpkl](https://github.com/z-jxy/rpkl)
Author
Owner

@Sir-NoChill commented on GitHub (Jun 13, 2024):

If any references are still needed for this, I have a rust binding here: https://github.com/z-jxy/pkl-rs

I don't think that is public

@Sir-NoChill commented on GitHub (Jun 13, 2024): > If any references are still needed for this, I have a rust binding here: [https://github.com/z-jxy/pkl-rs](url) I don't think that is public
Author
Owner

@z-jxy commented on GitHub (Jun 14, 2024):

If any references are still needed for this, I have a rust binding here: https://github.com/z-jxy/pkl-rs

I don't think that is public

Sorry link didn't paste right, should work now

@z-jxy commented on GitHub (Jun 14, 2024): > > If any references are still needed for this, I have a rust binding here: [https://github.com/z-jxy/pkl-rs](url) > > I don't think that is public Sorry link didn't paste right, should work now
Author
Owner

@Sir-NoChill commented on GitHub (Jun 27, 2024):

Alright, so I think I'm going to try to pull your codegen into my repo. Hecktic couple weeks, so sorry for the absence of activity.

Currently I am working on making the binding documentation a bit more robust and refining the API so that everything works well. @z-jxy what's your plan with your repo? I'm very open to the suggestion that my binding is a bit over-engineered for the moment, so I'm open to switching the bulk of the work to yours to make everything work there.

I also made a repo for illustrative purposes that uses my bindings here (I'll pin the version in the cargo).

@Sir-NoChill commented on GitHub (Jun 27, 2024): Alright, so I think I'm going to try to pull your codegen into my repo. Hecktic couple weeks, so sorry for the absence of activity. Currently I am working on making the binding documentation a bit more robust and refining the API so that everything works well. @z-jxy what's your plan with your repo? I'm very open to the suggestion that my binding is a bit over-engineered for the moment, so I'm open to switching the bulk of the work to yours to make everything work there. I also made a repo for illustrative purposes that uses my bindings [here](https://github.com/Sir-NoChill/pkl-rust-starter) (I'll pin the version in the cargo).
Author
Owner

@z-jxy commented on GitHub (Jun 27, 2024):

@Sir-NoChill I was planning to publish the crate after adding some more documentation and reorganizing some of the modules.

Also wanted to focus on improving the codegen since it doesn't provide much flexibility at the moment. For example, there's no way to specify derive attributes for generated structs. All attributes have to be added manually which could be time consuming for larger modules.

I made an issue for this here.

@z-jxy commented on GitHub (Jun 27, 2024): @Sir-NoChill I was planning to publish the crate after adding some more documentation and reorganizing some of the modules. Also wanted to focus on improving the codegen since it doesn't provide much flexibility at the moment. For example, there's no way to specify derive attributes for generated structs. All attributes have to be added manually which could be time consuming for larger modules. I made an issue for this [here](https://github.com/z-jxy/rpkl/issues/6).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#110