jid

package
v0.3.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2019 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithAndWithout

func WithAndWithout(peer Any) (WithResource, WithoutResource)

Types

type Any

type Any interface {
	// Host will always return the domain component, since all JIDs have one
	Host() Domain
	// String will return the natural string representation of the JID
	String() string
	// WithResource will return a new JID containing the resource component specified. If the JID already had a resource, it will be replaced
	WithResource(Resource) WithResource
	// MaybeWithResource will act like WithResource, if the argument is anything but a blank resource.
	// Otherwise it will return itself without a resource
	MaybeWithResource(Resource) Any
	// NoResource will ensure that the JID returned doesn't have a resource
	NoResource() WithoutResource
	// Potential resource returns the resource if one exists, or the blank resource otherwise
	PotentialResource() Resource
	// PotentialSplit will return the result of calling WithoutResource and PotentialResource
	PotentialSplit() (WithoutResource, Resource)
}

Any represents any valid JID, including just a hostname, a bare jid, and a jid with a resource

func Parse

func Parse(j string) Any

Parse will parse the given string and return the most specific JID type that matches it

type Bare

type Bare interface {
	WithoutResource
	WithLocal
}

Bare represents a JID containing both a local component and a host component, but no resource component. A Bare is an Any

type Domain

type Domain string

func (Domain) Host

func (j Domain) Host() Domain

Host implements Any

func (Domain) MaybeWithResource

func (j Domain) MaybeWithResource(r Resource) Any

MaybeWithResource implements WithoutResource

func (Domain) NoResource

func (j Domain) NoResource() WithoutResource

NoResource implements Any

func (Domain) PotentialResource

func (j Domain) PotentialResource() Resource

PotentialResource implements Any

func (Domain) PotentialSplit

func (j Domain) PotentialSplit() (WithoutResource, Resource)

PotentialSplit implements Any

func (Domain) String

func (j Domain) String() string

String implements Any

func (Domain) WithResource

func (j Domain) WithResource(r Resource) WithResource

WithResource implements WithoutResource

type Full

type Full interface {
	WithResource
	WithLocal
}

Full represents a JID containing a local, host and resource component. A Full is a Bare and an Any

type Local

type Local string

func MaybeLocal

func MaybeLocal(j Any) Local

MaybeLocal returns the local part of a JID if it has one, otherwise empty

type Resource

type Resource string

type WithLocal

type WithLocal interface {
	// Local returns the local part of the JID
	Local() Local
}

Local represents a JID that has a Local port

type WithResource

type WithResource interface {
	Any
	// Resource will return the resource
	Resource() Resource
	// Split will return the JID split into the part without resource and the part with resource
	Split() (WithoutResource, Resource)
}

WithResource represents any valid JID that has a resource part

func R

func R(s string) WithResource

R returns a JID with resource. This method will fail if the object doesn't have a resource

type WithoutResource

type WithoutResource interface {
	Any
	// contains filtered or unexported methods
}

WithoutResource represents any valid JID that does not have a resource part

func NR

func NR(s string) WithoutResource

NR returns a JID without a resource

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL