Documentation
¶
Index ¶
- Variables
- func ApplyFileDropVeto(payload InboundPayload, proposed cef.DragOperationsMask, ...) cef.DragOperationsMask
- func ApplyInboundPayload(data DragDataWriter, payload InboundPayload)
- func MetadataNeedsPlaceholder(metadata DragMetadata) bool
- func NewInboundDragData(payload InboundPayload) cef.DragData
- func NewMetadataDragData(metadata DragMetadata) cef.DragData
- type AsyncReader
- type AsyncSource
- type AsyncStream
- type DragDataWriter
- type DragMetadata
- type DroppedFile
- type InboundPayload
- type LimitScope
- type OutboundFormat
- type OutboundPayload
- type ReadLimits
- type ReadResult
- type TooLargeError
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnsupportedMIME = errors.New("drop has no supported MIME type") ErrCanceled = errors.New("asynchronous drop read canceled") ErrDetached = errors.New("asynchronous drop reader detached") ErrStaleGeneration = errors.New("asynchronous drop read generation is stale") ErrNilStream = errors.New("asynchronous drop read returned no stream") ErrUnexpectedMIME = errors.New("drop read returned an unexpected MIME type") )
var ( ErrMalformedPayload = errors.New("malformed inbound drag payload") ErrRemoteFileURI = errors.New("remote-host file URI is not allowed") )
Functions ¶
func ApplyFileDropVeto ¶
func ApplyFileDropVeto(payload InboundPayload, proposed cef.DragOperationsMask, allow func(paths []string) bool) cef.DragOperationsMask
ApplyFileDropVeto returns None when an optional file policy rejects the local paths. A nil policy, and payloads without files, are allowed.
func ApplyInboundPayload ¶
func ApplyInboundPayload(data DragDataWriter, payload InboundPayload)
ApplyInboundPayload fills the mutable CefDragData fields represented by payload.
func MetadataNeedsPlaceholder ¶
func MetadataNeedsPlaceholder(metadata DragMetadata) bool
func NewInboundDragData ¶
func NewInboundDragData(payload InboundPayload) cef.DragData
NewInboundDragData constructs a complete CefDragData from a decoded payload.
func NewMetadataDragData ¶
func NewMetadataDragData(metadata DragMetadata) cef.DragData
NewMetadataDragData creates the richest safe CEF enter object possible without reading the drop. Full external payload construction belongs to B-2.
Types ¶
type AsyncReader ¶
type AsyncReader struct {
// contains filtered or unexported fields
}
AsyncReader is a platform-independent callback state machine. It never calls a synchronous read method or starts a goroutine; the platform adapter owns scheduling each OpenAsync and ReadAsync operation.
func NewAsyncReader ¶
func NewAsyncReader(limits ReadLimits) *AsyncReader
func (*AsyncReader) Cancel ¶
func (r *AsyncReader) Cancel(generation uint64)
Cancel completes the matching generation and asks the platform operation to cancel. Late callbacks are harmless.
func (*AsyncReader) Detach ¶
func (r *AsyncReader) Detach()
Detach permanently invalidates the active generation.
func (*AsyncReader) Invalidate ¶
func (r *AsyncReader) Invalidate(generation uint64)
Invalidate marks the matching generation stale without detaching the reader.
func (*AsyncReader) Read ¶
func (r *AsyncReader) Read(advertised []string, source AsyncSource, done func(ReadResult)) uint64
Read starts a new generation. Starting a read makes any prior generation stale and completes it before opening the new source.
type AsyncSource ¶
type AsyncSource interface {
// The callback MIME is the actual type returned by the platform's finish call.
OpenAsync(mime string, callback func(AsyncStream, string, error))
Cancel()
}
AsyncSource opens one advertised MIME payload without blocking the caller.
type AsyncStream ¶
AsyncStream reads one chunk without blocking the caller. An empty chunk is EOF.
type DragDataWriter ¶
type DragDataWriter interface {
SetFragmentText(string)
SetFragmentHtml(string)
SetLinkURL(string)
SetLinkTitle(string)
AddFile(path, displayName string)
}
DragDataWriter is the subset of CefDragData used for inbound conversion.
type DragMetadata ¶
DragMetadata is the content classification available at ::enter, before any asynchronous payload read is permitted.
func MetadataFromFormats ¶
func MetadataFromFormats(formats []string) DragMetadata
func (DragMetadata) Has ¶
func (m DragMetadata) Has(format string) bool
type DroppedFile ¶
DroppedFile is a local file represented in a CEF drag payload.
type InboundPayload ¶
type InboundPayload struct {
Text string
HTML string
Files []DroppedFile
LinkURL string
LinkTitle string
}
InboundPayload is the decoded, platform-independent content of an external drop.
func ParseInboundPayload ¶
func ParseInboundPayload(mimeType string, data []byte) (InboundPayload, error)
ParseInboundPayload validates and decodes one MIME payload.
type LimitScope ¶
type LimitScope string
LimitScope identifies which bounded-read budget was exceeded.
const ( LimitPayload LimitScope = "payload" LimitCumulative LimitScope = "cumulative" )
type OutboundFormat ¶
OutboundFormat is one MIME value offered to a native drop target.
func OutboundFormats ¶
func OutboundFormats(payload OutboundPayload) []OutboundFormat
OutboundFormats serializes platform-independent drag content in a stable order.
type OutboundPayload ¶
type OutboundPayload struct {
Text string
HTML string
Files []string
LinkURL string
LinkTitle string
ImageMIME string
ImageBytes []byte
}
OutboundPayload is platform-independent content offered by an internal drag.
type ReadLimits ¶
type ReadLimits struct {
SupportedMIMEs []string
PayloadBytes int
CumulativeBytes int
ChunkBytes int
}
ReadLimits configures MIME preference and bounded asynchronous reads. A byte limit of zero disables that limit. ChunkBytes defaults to 64 KiB.
type ReadResult ¶
ReadResult is the exactly-once terminal result of a read operation.
type TooLargeError ¶
type TooLargeError struct {
Scope LimitScope
Limit int
Size int
}
TooLargeError is returned before an oversized chunk is retained.
func (*TooLargeError) Error ¶
func (e *TooLargeError) Error() string