linkset

package
v1.0.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2022 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

type Item struct {
	// contains filtered or unexported fields
}

Item contains a DID (in the HRef) and the previous anchor of the DID.

func NewItem

func NewItem(href, previous *url.URL) *Item

NewItem returns a new Item.

func (*Item) HRef

func (i *Item) HRef() *url.URL

HRef returns the DID (as a URI).

func (*Item) MarshalJSON

func (i *Item) MarshalJSON() ([]byte, error)

MarshalJSON marshals the object to JSON.

func (*Item) Previous

func (i *Item) Previous() *url.URL

Previous returns the previous anchor or nil (for create operations).

func (*Item) UnmarshalJSON

func (i *Item) UnmarshalJSON(b []byte) error

UnmarshalJSON umarshals the object from JSON.

type Link struct {
	// contains filtered or unexported fields
}

Link is part of a Linkset.

func NewAnchorLink(anchor, author, profile *url.URL, item []*Item) *Link

NewAnchorLink returns a new anchor Link.

func NewLink(anchor, author, profile *url.URL, original, related, replies *Reference) *Link

NewLink returns a new Link.

func NewRelatedLink(anchor, profile, via *url.URL, up ...*url.URL) *Link

NewRelatedLink returns a new related Link.

func (*Link) Anchor

func (l *Link) Anchor() *url.URL

Anchor returns the anchor URI.

func (*Link) Author

func (l *Link) Author() *url.URL

Author returns the originator of the anchor.

func (*Link) Items

func (l *Link) Items() []*Item

Items returns the items contained within the link.

func (*Link) MarshalJSON

func (l *Link) MarshalJSON() ([]byte, error)

MarshalJSON marshals the object to JSON.

func (*Link) Original

func (l *Link) Original() *Reference

Original returns the original reference.

func (*Link) Profile

func (l *Link) Profile() *url.URL

Profile returns the profile used to generate the link.

func (*Link) Related

func (l *Link) Related() *Reference

Related returns the related reference.

func (*Link) Replies

func (l *Link) Replies() *Reference

Replies returns a collection of replies to the original resource. (For example, verifiable credentials.)

func (*Link) UnmarshalJSON

func (l *Link) UnmarshalJSON(b []byte) error

UnmarshalJSON umarshals the object from JSON.

func (*Link) Up

func (l *Link) Up() []*url.URL

Up returns a set of parents.

func (*Link) Validate

func (l *Link) Validate() error

Validate validates the link.

func (*Link) Via

func (l *Link) Via() *url.URL

Via returns the "via" relationship.

type LinkType

type LinkType = string

LinkType defines the type of the link.

const (
	// TypeLinkset indicates that the content type is a linkset in JSON format.
	TypeLinkset LinkType = "application/linkset+json"
	// TypeJSONLD indicates that the content type is JSON LD.
	TypeJSONLD LinkType = "application/ld+json"
)

type Linkset

type Linkset struct {
	Linkset []*Link `json:"linkset"`
}

Linkset contains one or more Links.

func New

func New(linkset ...*Link) *Linkset

New returns a new Linkset.

func (ls *Linkset) Link() *Link

Link returns the first link in the Linkset or nil if the Linkset is empty.

type Reference

type Reference struct {
	// contains filtered or unexported fields
}

Reference contains a URI and the content type of the data at that URI.

func NewAnchorRef

func NewAnchorRef(data []byte, uriMediaType datauri.MediaType, contentType LinkType) (*url.URL, *Reference, error)

NewAnchorRef creates a data URI Reference of the given content type and returns the anchor URI (which is a hashlink of the data).

func NewReference

func NewReference(u *url.URL, hrefType string) *Reference

NewReference returns a new reference.

func (*Reference) Content

func (r *Reference) Content() ([]byte, error)

Content returns the decoded content of a data URI reference. If the reference is not a data URI then an error is returned.

func (*Reference) HRef

func (r *Reference) HRef() *url.URL

HRef returns the reference.

func (*Reference) Linkset

func (r *Reference) Linkset() (*Linkset, error)

Linkset decodes the data URI in href and unmarshals and returns the Linkset. If the reference is not a data URI or the type is not application/linkset+json then an error is returned.

func (*Reference) MarshalJSON

func (r *Reference) MarshalJSON() ([]byte, error)

MarshalJSON marshals the object to JSON.

func (*Reference) Type

func (r *Reference) Type() string

Type returns the content-type of the reference.

func (*Reference) UnmarshalJSON

func (r *Reference) UnmarshalJSON(b []byte) error

UnmarshalJSON umarshals the object from JSON.

Jump to

Keyboard shortcuts

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