obus
Rules
type argument_filter =
Type of an argument filter. Argument filters are used in match rules to match message arguments.
type arguments = private (int * argument_filter) list
Type of lists of argument filters. The private type ensures that such lists are always sorted by argument number, do not contain duplicates and indexes are in the range 0..63
..
val make_arguments : (int * argument_filter) list -> arguments
Creates an arguments filter from a list of filters. It raises Invalid_argument
if one of the argument filters use a number outside of the range 1..63
val cast_arguments : arguments -> (int * argument_filter) list
Returns the list of filters for the given arguments filter.
type rule = {
typ : [ `Signal | `Error | `Method_call | `Method_return ] option; |
sender : OBus_name.bus; |
interface : OBus_name.interface; |
member : OBus_name.member; |
path : OBus_path.t option; |
destination : OBus_name.bus; |
arguments : arguments; |
eavesdrop : bool option; |
}
Type of a rule used to match a message
Rule projections
val typ : rule -> [ `Signal | `Error | `Method_call | `Method_return ] option
val sender : rule -> OBus_name.bus
val interface : rule -> OBus_name.interface
val member : rule -> OBus_name.member
val path : rule -> OBus_path.t option
val destination : rule -> OBus_name.bus
val eavesdrop : rule -> bool option
Rule construction
val rule :
?typ:[ `Signal | `Error | `Method_call | `Method_return ] ->
?sender:OBus_name.bus ->
?interface:OBus_name.interface ->
?member:OBus_name.member ->
?path:OBus_path.t ->
?destination:OBus_name.bus ->
?arguments:arguments ->
?eavesdrop:bool ->
unit ->
rule
Create a matching rule.
Matching
val match_message : rule -> OBus_message.t -> bool
match_message rule message
returns wether message
is matched by rule
val match_values : arguments -> OBus_value.V.sequence -> bool
match_values filters values
returns whether values
are matched by the given list of argument filters.
Comparison
type comparison_result =
Result of the comparisong of two rules r1
and r2
:
val compare_rules : rule -> rule -> comparison_result
compare_rules r1 r2
compares the two matching rules r1
and r2
Parsing/printing
Parse_failure(string, position, reason)
is raised when parsing a rule failed
val string_of_rule : rule -> string
Returns a string representation of a matching rule.
val rule_of_string : string -> rule
Parse a string representation of a matching rule.
Rules and message buses
val export : ?switch:Lwt_switch.t -> OBus_connection.t -> rule -> unit Lwt.t
export ?switch connection rule
registers rule
on the message bus. If another rule more general than rule
is already exported, then it does nothihng.
You can provide a switch to manually disable the export.