mirror of
https://github.com/zap-proto/ocaml-rpc.git
synced 2026-10-30 15:04:28 +00:00
Makes it match the new package names, and also will shrink the diff for the Eio port.
23 lines
717 B
OCaml
23 lines
717 B
OCaml
type t =
|
|
| Field of int
|
|
|
|
let pp f = function
|
|
| Field i -> Fmt.pf f "field-%d" i
|
|
|
|
let to_cap_index = function
|
|
| None -> None
|
|
| Some i -> Some (Stdint.Uint32.to_int i)
|
|
|
|
(* [walk ss x xs] is the interface cap index at path [x :: xs] within struct storage [ss]. *)
|
|
let rec walk ss x = function
|
|
| Field x2 :: xs -> walk (Schema.ReaderOps.get_struct ss x) x2 xs
|
|
| [] -> Schema.ReaderOps.get_interface ss x |> to_cap_index
|
|
|
|
let resolve payload path =
|
|
let open Schema.Reader in
|
|
match path with
|
|
| [] -> Payload.content_get_interface payload |> to_cap_index (* Bootstrap only *)
|
|
| Field x :: xs ->
|
|
let ss = Payload.content_get payload |> Schema.ReaderOps.deref_opt_struct_pointer in
|
|
walk ss x xs
|