You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AFAICS the generator will always define a native Rust struct and offload the
derivation of Deserialize and Serialize to Serde. Often it would be
convenient if custom serialization could be made to work for Varlink types. The
motivation is mainly to prevent extra copies / conversions when working with
FFI.
IOW currently the path between JSON and opaque FFI type is JSON ←→ Rust struct
←→ FFI struct; ideally it would be just JSON ←→ FFI struct.
Say I have an interface
interface bar.foo
type Foo (
one: string,
two: int
)
method GetFoo() -> (foo: Foo)
Varlink will define a struct Foo containing those fields and a trait Call_GetFoo that handles such a struct. Now I’m actually converting the
struct directly into some opaque FFI type:
Cool. Another situation where assigning custom types would be beneficial is when
you have a &str or Cow<'a, str> and want to serialize those into a
varlink string without creating an owned String. That probably only
works in one direction though.
AFAICS the generator will always define a native Rust struct and offload the
derivation of
Deserialize
andSerialize
to Serde. Often it would beconvenient if custom serialization could be made to work for Varlink types. The
motivation is mainly to prevent extra copies / conversions when working with
FFI.
IOW currently the path between JSON and opaque FFI type is JSON ←→ Rust struct
←→ FFI struct; ideally it would be just JSON ←→ FFI struct.
Say I have an interface
Varlink will define a
struct Foo
containing those fields and a traitCall_GetFoo
that handles such a struct. Now I’m actually converting thestruct directly into some opaque FFI type:
discarding the Rust struct immediately after.
I’m looking for a way of hooking into the varlink generator so it defines an
alternative to
Call_GetFoo
that instead uses the newtypeFFI_FOO_PTR
:which has implementations for
Deserialize
andSerialize
.The text was updated successfully, but these errors were encountered: