Skip to main content

KvmSession

Struct KvmSession 

Source
pub struct KvmSession<'a, M: ReceiverMode> { /* private fields */ }
Expand description

Exclusive remote control of the source a receiver is connected to.

Created by Receiver::kvm, which borrows the receiver mutably, so a receiver has at most one session at a time. The session lends the receiver back as a restricted KvmReceiver through receiver, so frames can be captured, and held, while keys, buttons and touches stay pressed across them. The view offers mode-permitted capture, tally, PTZ, statistics and metadata, without allowing application connection changes. For a packet session, session.receiver() delivers owned or borrowed packets, decoded media and events through its mode-specific capture methods.

To change source, successfully release_all, end the session, change the connection through its owner, then start a new session. Native disconnection, Discovery Server remote control and failed release delivery can still leave input pressed on the previous source: release is best effort and the session cannot address a source it has lost.

The session never reads the local clipboard: it sends only the text it is given. It is Send and Sync, as the receiver is; its input methods take &mut self, so one thread at a time sends input.

Every method that sends a message returns Error::NativeOperationFailed, naming the SDK function, when the SDK did not send it. Success is not a confirmation that the source acted on the message. The session remembers which keys, buttons and touches it has pressed, and dropping it releases them on a best-effort basis; call release_all to learn whether that succeeded.

Implementations§

Source§

impl<'a, M: ReceiverMode> KvmSession<'a, M>

Source

pub fn receiver(&self) -> KvmReceiver<'a, M>

Restricted receiver access for the session’s original receiver lifetime.

A frame captured through it can be held while the session’s input methods run, which is how a key, button or touch stays down across captured frames. The view cannot change the connection or recover an unrestricted receiver, even when moved to a scoped thread. Creating it allocates nothing and makes no SDK call or lock acquisition.

Source

pub fn is_supported(&self) -> bool

Whether the connected source accepts remote control. This can change during the session when that source enables or disables remote control.

Source

pub fn mouse_down(&mut self, button: MouseButton) -> Result<()>

Press a mouse button.

§Errors

Error::NativeOperationFailed when the SDK did not send the press.

Source

pub fn mouse_up(&mut self, button: MouseButton) -> Result<()>

Release a mouse button.

§Errors

Error::NativeOperationFailed when the SDK did not send the release; the button stays recorded as pressed.

Source

pub fn key_down(&mut self, keysym: u32) -> Result<()>

Press a key, identified by its X11 key symbol.

§Errors

Error::InvalidInput when the symbol is outside the range the SDK accepts, and Error::NativeOperationFailed when the SDK did not send the press.

Source

pub fn key_up(&mut self, keysym: u32) -> Result<()>

Release a key, identified by its X11 key symbol.

§Errors

As for key_down; a key whose release the SDK did not send stays recorded as pressed.

Source

pub fn wheel(&mut self, axis: WheelAxis, units: f32) -> Result<()>

Turn a mouse wheel by units notches; the sign gives the direction.

§Errors

Error::InvalidInput when units is not finite, and Error::NativeOperationFailed when the SDK did not send the turn.

Source

pub fn move_pointer(&mut self, x: f32, y: f32) -> Result<()>

Move the pointer to (x, y), each a fraction of the source’s screen from 0.0 (left, top) to 1.0 (right, bottom).

§Errors

Error::InvalidInput when a coordinate is outside 0.0..=1.0, and Error::NativeOperationFailed when the SDK did not send the move.

Source

pub fn set_clipboard_text(&mut self, text: &str) -> Result<()>

Replace the source’s clipboard text.

§Errors

Error::InvalidCString when text contains a NUL, and Error::NativeOperationFailed when the SDK did not send the text.

Source

pub fn touch(&mut self, points: &[[f32; 2]]) -> Result<()>

Report the current touch points, each an [x, y] fraction of the source’s screen. An empty slice sends the same lift as finish_touch.

§Errors

Error::InvalidInput when a coordinate is outside 0.0..=1.0 or there are more points than the SDK can count, and Error::NativeOperationFailed when the SDK did not send them.

Source

pub fn finish_touch(&mut self) -> Result<()>

Lift every touch.

§Errors

Error::NativeOperationFailed when the SDK did not send the lift; the touches stay recorded.

Source

pub fn release_all(&mut self) -> Result<()>

Release every key, button and touch this session has pressed.

§Errors

Error::NativeOperationFailed for the first release the SDK did not send. Every release is still attempted; those the SDK did not send stay recorded as pressed, and a later call tries them again.

Trait Implementations§

Source§

impl<M: ReceiverMode> Debug for KvmSession<'_, M>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<M: ReceiverMode> Drop for KvmSession<'_, M>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'a, M> Freeze for KvmSession<'a, M>

§

impl<'a, M> RefUnwindSafe for KvmSession<'a, M>
where M: RefUnwindSafe,

§

impl<'a, M> Send for KvmSession<'a, M>

§

impl<'a, M> Sync for KvmSession<'a, M>

§

impl<'a, M> Unpin for KvmSession<'a, M>

§

impl<'a, M> UnsafeUnpin for KvmSession<'a, M>

§

impl<'a, M> UnwindSafe for KvmSession<'a, M>
where M: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.