Skip to main content

FrameLimit

Struct FrameLimit 

Source
pub struct FrameLimit { /* private fields */ }
Expand description

How many frames a second the runtime draws at most, for a local and for a remote connection.

An application answers with one from App::frame_limit. The limit merges frames the application’s own work causes: output of an embedded terminal, messages of background work, a running animation. It never holds back a frame that answers a key, a paste, a mouse button going down or a button coming up — the echo of a typed character, the answer to a click and the place a dragged window comes to rest are drawn at once, so the limit cannot be felt in the keyboard or in a click.

The pointer moving is merged too: a drag, the pointer passing over the screen and the wheel arrive as fast as the hand moves, and only the latest state is worth a frame. Every one of those events still reaches the widgets and the application, which apply them all; only the drawing waits, at most one gap of the limit, and the first motion after a rest that long is drawn at once. So a two-second window drag at 5 frames a second writes ten frames, not a frame for every cell the pointer crossed.

The default draws 60 frames a second locally and 20 over a remote connection (Env::remote), because on a slow link every frame is a screen written down a network: a program pouring out lines would otherwise spend the connection on frames nobody can read apart.

use qframe::prelude::*;
use qframe::runtime::FrameLimit;

// The default: 60 frames a second at the machine, 20 over SSH.
assert_eq!(FrameLimit::default().frames_per_second(false), Some(60));
assert_eq!(FrameLimit::default().frames_per_second(true), Some(20));

// The same number everywhere, or a quieter one on a remote connection.
assert_eq!(FrameLimit::per_second(30).frames_per_second(true), Some(30));
assert_eq!(FrameLimit::per_second(30).remote(10).frames_per_second(true), Some(10));

// Every frame that is wanted is drawn.
assert_eq!(FrameLimit::none().frames_per_second(false), None);

Implementations§

Source§

impl FrameLimit

Source

pub const LOCAL: u32 = 60

Frames a second the default draws locally: as many as a screen at 60 Hz shows.

Source

pub const REMOTE: u32 = 20

Frames a second the default draws over a remote connection: fast enough to read a scrolling program by, cheap enough for a link that carries every frame.

Source

pub fn per_second(frames: u32) -> Self

The same number of frames a second on every connection. A frames of zero is no limit, the way FrameLimit::none is; a limit of no frames would draw nothing at all.

Source

pub fn none() -> Self

No limit: every frame the application asks for is drawn.

Source

pub fn remote(self, frames: u32) -> Self

Draws frames a second over a remote connection instead, and leaves the local number as it is. A frames of zero lifts the limit for remote connections.

Source

pub fn frames_per_second(self, remote: bool) -> Option<u32>

How many frames a second this limit allows on the connection in hand; None is no limit. remote is what Env::remote reports.

Trait Implementations§

Source§

impl Clone for FrameLimit

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for FrameLimit

Source§

impl Debug for FrameLimit

Source§

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

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

impl Default for FrameLimit

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for FrameLimit

Source§

impl PartialEq for FrameLimit

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for FrameLimit

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.