Documentation
¶
Overview ¶
Package clipboard defines bounded, transport-free access to a native system clipboard. Hosts choose a backend and policy; this package performs no remote routing, approval UI, permission prompting, or implicit restoration.
Index ¶
- Constants
- Variables
- func Code(err error) string
- func ValidateItems(items []Item, maxBytes int64, formats []string) error
- func ValidatePolicy(policy Policy) error
- func ValidateSnapshot(snapshot Snapshot, maxBytes int64, formats []string) error
- type Backend
- type Clipboard
- func (c *Clipboard) Clear(ctx context.Context, expectedGeneration string) (Receipt, error)
- func (c *Clipboard) Generation(ctx context.Context) (string, error)
- func (c *Clipboard) Read(ctx context.Context) (Snapshot, error)
- func (c *Clipboard) Write(ctx context.Context, request WriteRequest) (Receipt, error)
- type Item
- type Policy
- type Receipt
- type Representation
- type Snapshot
- type WriteRequest
Constants ¶
const ( MaxPolicyBytes = 16 << 20 MaxItems = 64 MaxFormats = 32 )
Variables ¶
Functions ¶
func Code ¶ added in v0.4.0
Code is the stable error code of err for another language to match: invalid, denied, too_large or changed. It is empty for an error this package does not define.
func ValidatePolicy ¶
Types ¶
type Backend ¶
type Backend interface {
Generation(context.Context) (string, error)
Read(context.Context, int64, []string) (Snapshot, error)
Write(context.Context, WriteRequest, int64, []string) (Receipt, error)
}
Backend serializes operations and compares ExpectedGeneration immediately before mutation. Native clipboard APIs may still lack cross-process atomicity.
type Clipboard ¶
type Clipboard struct {
// contains filtered or unexported fields
}
func (*Clipboard) Generation ¶
Generation returns mutation metadata without reading clipboard contents. It lets a write-only client perform a conditional write without gaining read access.
type Item ¶
type Item struct {
Representations []Representation `json:"representations"`
}
type Policy ¶
type Policy struct {
MaxBytes int64 `json:"maxBytes"`
AllowedFormats []string `json:"allowedFormats"`
AllowRead bool `json:"allowRead"`
AllowWrite bool `json:"allowWrite"`
}
Policy is fixed by the embedding application before native access begins.
type Representation ¶
type Snapshot ¶
Snapshot is a finite copy. Generation is opaque and is only meaningful to the backend instance that produced it.