API Reference
API Reference
Section titled “API Reference”Rust FFI API for Flutter integration.
Initialization
Section titled “Initialization”initToss
Section titled “initToss”Initialize the Toss core library.
api.initToss( dataDir: '/path/to/data', deviceName: 'My Device',);Parameters:
dataDir: Path to data directorydeviceName: Friendly device name
Returns: void
Device Management
Section titled “Device Management”getDeviceId
Section titled “getDeviceId”Get the current device’s unique identifier.
String deviceId = api.getDeviceId();Returns: String - Device ID
setDeviceName
Section titled “setDeviceName”Set the device’s friendly name.
api.setDeviceName(name: 'My Device');Parameters:
name: Device name
Returns: void
Pairing
Section titled “Pairing”startPairing
Section titled “startPairing”Start a pairing session.
PairingInfo info = await api.startPairing();Returns: PairingInfo with:
code: 6-digit pairing codeqrData: QR code dataexpiresAt: Expiration timestamppublicKey: Public key for pairing
completePairingQr
Section titled “completePairingQr”Complete pairing using QR code.
bool success = await api.completePairingQr( qrData: 'qr-code-data',);Parameters:
qrData: QR code data from other device
Returns: bool - Success status
completePairingCode
Section titled “completePairingCode”Complete pairing using 6-digit code.
bool success = await api.completePairingCode( code: '123456',);Parameters:
code: 6-digit pairing code
Returns: bool - Success status
Device List
Section titled “Device List”getPairedDevices
Section titled “getPairedDevices”Get list of paired devices.
List<DeviceInfo> devices = await api.getPairedDevices();Returns: List<DeviceInfo> with:
id: Device IDname: Device nameisOnline: Online statuslastSeen: Last seen timestamp
Clipboard Operations
Section titled “Clipboard Operations”sendClipboard
Section titled “sendClipboard”Send clipboard content to paired devices.
bool success = await api.sendClipboard( contentType: 'text/plain', content: 'Hello, World!',);Parameters:
contentType: MIME type of contentcontent: Base64-encoded content
Returns: bool - Success status
getClipboardHistory
Section titled “getClipboardHistory”Get clipboard history.
List<ClipboardItemInfo> history = await api.getClipboardHistory( limit: 50,);Parameters:
limit: Maximum number of items
Returns: List<ClipboardItemInfo> with:
contentType: Content typepreview: Preview textsizeBytes: Size in bytestimestamp: TimestampsourceDevice: Source device ID
Events
Section titled “Events”pollEvent
Section titled “pollEvent”Poll for network events.
NetworkEvent? event = await api.pollEvent();Returns: NetworkEvent? - Event or null if none
Settings
Section titled “Settings”getSettings
Section titled “getSettings”Get current settings.
TossSettings settings = await api.getSettings();Returns: TossSettings with:
autoSync: Auto-sync enabledsyncText: Sync text contentsyncImages: Sync imagessyncFiles: Sync filesmaxFileSizeMb: Max file size in MBhistoryEnabled: History enabledhistoryDays: History retention daysrelayUrl: Relay server URL
updateSettings
Section titled “updateSettings”Update settings.
api.updateSettings(settings: settings);Parameters:
settings: Updated settings object
Returns: void
Error Handling
Section titled “Error Handling”All API functions may throw exceptions. Handle errors appropriately:
try { await api.startPairing();} catch (e) { print('Error: $e');}Next Steps
Section titled “Next Steps”- Architecture - System design
- Platform Support - Platform-specific details
- Testing - Testing guide