Sha256: 1f339c7c2baa4bab09dab3e5f2dabeb08e92cd8bf62b80018d955f809d8da213

Contents?: true

Size: 1.85 KB

Versions: 16

Compression:

Stored size: 1.85 KB

Contents

package dbus

import (
	"strings"
)

// MatchOption specifies option for dbus routing match rule. Options can be constructed with WithMatch* helpers.
// For full list of available options consult
// https://dbus.freedesktop.org/doc/dbus-specification.html#message-bus-routing-match-rules
type MatchOption struct {
	key   string
	value string
}

func formatMatchOptions(options []MatchOption) string {
	items := make([]string, 0, len(options))
	for _, option := range options {
		items = append(items, option.key+"='"+option.value+"'")
	}
	return strings.Join(items, ",")
}

// WithMatchOption creates match option with given key and value
func WithMatchOption(key, value string) MatchOption {
	return MatchOption{key, value}
}

// doesn't make sense to export this option because clients can only
// subscribe to messages with signal type.
func withMatchType(typ string) MatchOption {
	return WithMatchOption("type", typ)
}

// WithMatchSender sets sender match option.
func WithMatchSender(sender string) MatchOption {
	return WithMatchOption("sender", sender)
}

// WithMatchSender sets interface match option.
func WithMatchInterface(iface string) MatchOption {
	return WithMatchOption("interface", iface)
}

// WithMatchMember sets member match option.
func WithMatchMember(member string) MatchOption {
	return WithMatchOption("member", member)
}

// WithMatchObjectPath creates match option that filters events based on given path
func WithMatchObjectPath(path ObjectPath) MatchOption {
	return WithMatchOption("path", string(path))
}

// WithMatchPathNamespace sets path_namespace match option.
func WithMatchPathNamespace(namespace ObjectPath) MatchOption {
	return WithMatchOption("path_namespace", string(namespace))
}

// WithMatchDestination sets destination match option.
func WithMatchDestination(destination string) MatchOption {
	return WithMatchOption("destination", destination)
}

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ruby_snowflake_client-1.3.7 ext/vendor/github.com/godbus/dbus/match.go
ruby_snowflake_client-1.3.6 ext/vendor/github.com/godbus/dbus/match.go
ruby_snowflake_client-1.3.5 ext/vendor/github.com/godbus/dbus/match.go
ruby_snowflake_client-1.3.4 ext/vendor/github.com/godbus/dbus/match.go
ruby_snowflake_client-1.3.4.pre.debug ext/vendor/github.com/godbus/dbus/match.go
ruby_snowflake_client-1.3.3.pre.debug ext/vendor/github.com/godbus/dbus/match.go
ruby_snowflake_client-1.3.2 ext/vendor/github.com/godbus/dbus/match.go
ruby_snowflake_client-1.3.1 ext/vendor/github.com/godbus/dbus/match.go
ruby_snowflake_client-1.3.0 ext/vendor/github.com/godbus/dbus/match.go
ruby_snowflake_client-1.2.1 ext/vendor/github.com/godbus/dbus/match.go
ruby_snowflake_client-1.2.0 ext/vendor/github.com/godbus/dbus/match.go
ruby_snowflake_client-1.1.1 ext/vendor/github.com/godbus/dbus/match.go
ruby_snowflake_client-1.1.0 ext/vendor/github.com/godbus/dbus/match.go
ruby_snowflake_client-1.0.2 ext/vendor/github.com/godbus/dbus/match.go
ruby_snowflake_client-1.0.1 ext/vendor/github.com/godbus/dbus/match.go
ruby_snowflake_client-1.0.0 ext/vendor/github.com/godbus/dbus/match.go