transfer

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: MIT, Unlicense Imports: 4 Imported by: 0

Documentation

Overview

Package transfer contains operations and events for brokering data transfers.

The transfer protocol is as follows:

  • Data sources are registered with SourceOps, data targets with TargetOps.
  • A data source receives a RequestEvent when a transfer is initiated. It must respond with an OfferOp.
  • The target receives a DataEvent when transferring to it. It must close the event data after use.

When a user initiates a pointer-guided drag and drop transfer, the source as well as all potential targets receive an InitiateEvent. Potential targets are targets with at least one MIME type in common with the source. When a drag gesture completes, a CancelEvent is sent to the source and all potential targets.

Note that the RequestEvent is sent to the source upon drop.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CancelEvent

type CancelEvent struct{}

CancelEvent is sent to data sources and targets to cancel the effects of an InitiateEvent.

func (CancelEvent) ImplementsEvent

func (CancelEvent) ImplementsEvent()

type DataEvent

type DataEvent struct {
	// Type is the MIME type of Data.
	Type string
	// Open returns the transfer data. It is only valid to call Open in the frame
	// the DataEvent is received. The caller must close the return value after use.
	Open func() io.ReadCloser
}

DataEvent is sent to the target receiving the transfer.

func (DataEvent) ImplementsEvent

func (DataEvent) ImplementsEvent()

type InitiateEvent

type InitiateEvent struct{}

InitiateEvent is sent to a data source when a drag-and-drop transfer gesture is initiated.

Potential data targets also receive the event.

func (InitiateEvent) ImplementsEvent

func (InitiateEvent) ImplementsEvent()

type OfferOp

type OfferOp struct {
	Tag event.Tag
	// Type is the MIME type of Data.
	// It must be the Type from the corresponding RequestEvent.
	Type string
	// Data contains the offered data. It is closed when the
	// transfer is complete or cancelled.
	// Data must be kept valid until closed, and it may be used from
	// a goroutine separate from the one processing the frame..
	Data io.ReadCloser
}

OfferOp is used by data sources as a response to a RequestEvent.

func (OfferOp) Add

func (op OfferOp) Add(o *op.Ops)

Add the offer to the list of operations. It panics if the Data field is not set.

type RequestEvent

type RequestEvent struct {
	// Type is the first matched type between the source and the target.
	Type string
}

RequestEvent requests data from a data source. The source must respond with an OfferOp.

func (RequestEvent) ImplementsEvent

func (RequestEvent) ImplementsEvent()

type SourceOp

type SourceOp struct {
	Tag event.Tag
	// Type is the MIME type supported by this source.
	Type string
}

SourceOp registers a tag as a data source for a MIME type. Use multiple SourceOps if a tag supports multiple types.

func (SourceOp) Add

func (op SourceOp) Add(o *op.Ops)

type TargetOp

type TargetOp struct {
	Tag event.Tag
	// Type is the MIME type accepted by this target.
	Type string
}

TargetOp registers a tag as a data target. Use multiple TargetOps if a tag supports multiple types.

func (TargetOp) Add

func (op TargetOp) Add(o *op.Ops)

Jump to

Keyboard shortcuts

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