pub struct PasteboardServiceClient<R: ReadWrite> { /* private fields */ }Implementations§
Source§impl<R: ReadWrite> PasteboardServiceClient<R>
impl<R: ReadWrite> PasteboardServiceClient<R>
pub fn new(inner: RemoteXpcClient<R>) -> Self
Sourcepub async fn get(
&mut self,
pasteboard_name: &str,
) -> Result<PasteboardSnapshot, IdeviceError>
pub async fn get( &mut self, pasteboard_name: &str, ) -> Result<PasteboardSnapshot, IdeviceError>
Pull pasteboard_name with every item’s bytes inlined
(DataInclusionPolicy::AllResolved).
Sourcepub async fn get_with_policy(
&mut self,
pasteboard_name: &str,
policy: DataInclusionPolicy,
) -> Result<PasteboardSnapshot, IdeviceError>
pub async fn get_with_policy( &mut self, pasteboard_name: &str, policy: DataInclusionPolicy, ) -> Result<PasteboardSnapshot, IdeviceError>
Pull pasteboard_name with an explicit data-inclusion policy. Use a
promising policy plus PasteboardSnapshot::promised_items +
resolve to avoid transferring large items you don’t
need.
Sourcepub async fn set_text(
&mut self,
text: &str,
pasteboard_name: &str,
) -> Result<(), IdeviceError>
pub async fn set_text( &mut self, text: &str, pasteboard_name: &str, ) -> Result<(), IdeviceError>
Replace the contents of pasteboard_name with a single UTF-8 text value.
Sourcepub async fn set_image(
&mut self,
bytes: &[u8],
uti: &str,
pasteboard_name: &str,
) -> Result<(), IdeviceError>
pub async fn set_image( &mut self, bytes: &[u8], uti: &str, pasteboard_name: &str, ) -> Result<(), IdeviceError>
Replace the contents of pasteboard_name with a single image item of the
given uti (e.g. UTI_PNG) and its encoded bytes.
Sourcepub async fn resolve(
&mut self,
pasteboard_name: &str,
item_index: i64,
uti: &str,
) -> Result<Option<Vec<u8>>, IdeviceError>
pub async fn resolve( &mut self, pasteboard_name: &str, item_index: i64, uti: &str, ) -> Result<Option<Vec<u8>>, IdeviceError>
Fetch the bytes of a promised item (RESOLVE -> DATA). item_index is
the item’s position in the snapshot and uti is the type to resolve.
Returns None when the device can’t fulfil the promise — e.g. the
snapshot was superseded by a newer pasteboard change, or the data is no
longer available (the DATA reply carries a null data).
Sourcepub async fn resolve_raw(
&mut self,
pasteboard_name: &str,
item_index: i64,
uti: &str,
) -> Result<Value, IdeviceError>
pub async fn resolve_raw( &mut self, pasteboard_name: &str, item_index: i64, uti: &str, ) -> Result<Value, IdeviceError>
Like resolve but returns the raw DATA reply for
callers that need to inspect it (e.g. an error instead of data).
Sourcepub async fn set_change_notifications(
&mut self,
enable: bool,
pasteboard_name: &str,
policy: Option<DataInclusionPolicy>,
) -> Result<(), IdeviceError>
pub async fn set_change_notifications( &mut self, enable: bool, pasteboard_name: &str, policy: Option<DataInclusionPolicy>, ) -> Result<(), IdeviceError>
Subscribe to (or, with enable = false, unsubscribe from) pasteboard
change notifications. While subscribed the device pushes PUSH snapshots
as the pasteboard changes; read them with recv_push.
policy controls whether the pushed snapshots carry inline bytes.
The request is sent one-way: the device does not reply on the reply
channel, it just begins pushing PUSH messages on the root channel.
Sourcepub async fn recv_push(&mut self) -> Result<PasteboardSnapshot, IdeviceError>
pub async fn recv_push(&mut self) -> Result<PasteboardSnapshot, IdeviceError>
Block for the next PUSH change-notification snapshot from the device.
Only meaningful after set_change_notifications
with enable = true.
Pushes arrive on the root channel (not the reply channel that request/reply verbs use), so this reads from there.
Trait Implementations§
Source§impl RsdService for PasteboardServiceClient<Box<dyn ReadWrite>>
Available on crate feature rsd only.
impl RsdService for PasteboardServiceClient<Box<dyn ReadWrite>>
rsd only.