package wayland

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Wayland.MsgSource

Building and parsing messages.

Sourcetype ('a, 'rw) t constraint 'rw = [< `R | `W ]

An ('a, 'rw) t is a message for the 'a interface. 'rw is `R for an incoming message to be read, or `W for an outgoing message to be written.

Sourceval pp_args : Metadata.arg list -> (_, _) t Fmt.t

pp_args types is a formatter for messages with argument types types.

Reading messages

Sourceval parse : fds:Unix.file_descr Queue.t -> Cstruct.t -> ('a, [ `R ]) t option

parse ~fds buf returns the first message in buf, if any. When get_fd is called, it will take one from fds. Returns None if buf does not contain a complete message.

Sourceval obj : (_, _) t -> int32

obj t is the object ID in the message header.

Sourceval op : (_, _) t -> int

op t is the operation ID in the message header.

Sourceval length : (_, _) t -> int

length t is the total size of the message (including any space for arguments not yet added).

Sourceval get_int : (_, _) t -> int32

get_int t returns the next argument (which must be an integer) from t and advances the next-argument pointer.

Sourceval get_string : (_, _) t -> string

get_string t returns the next argument (which must be a string) from t and advances the next-argument pointer. The string returned does not include the trailing '\0'.

Sourceval get_string_opt : (_, _) t -> string option

get_string_opt t returns the next argument (which must be a string or NULL) from t and advances the next-argument pointer. The string returned does not include the trailing '\0'.

Sourceval get_array : (_, _) t -> string

get_array t returns the next argument (which must be array) from t and advances the next-argument pointer.

Sourceval get_fd : (_, _) t -> Unix.file_descr

get_fd t takes the next FD from the queue. It raises an exception if the queue is empty. Note that the Wayland protocol does not indicate which FDs below to which messages, so if used incorrectly this will remove FDs intended for other messages. The caller takes ownership of the FD and is responsible for closing it.

Sourceval get_fixed : (_, _) t -> Fixed.t

get_fixed t returns the next argument (which must be a fixed-point number) from t and advances the next-argument pointer.

Generating messages

Sourceval alloc : obj:int32 -> op:int -> ints:int -> strings:string option list -> arrays:string list -> ('a, [ `W ]) t
Sourceval add_int : (_, [ `W ]) t -> int32 -> unit
Sourceval add_string : (_, [ `W ]) t -> string -> unit
Sourceval add_string_opt : (_, [ `W ]) t -> string option -> unit
Sourceval add_array : (_, [ `W ]) t -> string -> unit
Sourceval add_fd : (_, [ `W ]) t -> Unix.file_descr -> unit

add_fd t fd adds a copy of fd (made with Unix.dup) to the message.

Sourceval add_fixed : (_, [ `W ]) t -> Fixed.t -> unit
OCaml

Innovation. Community. Security.