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
only merges frames the application’s own work causes: output of an embedded terminal, messages
of background work, a running animation. A frame the user asked for is never held back — the
echo of a typed character, the tone under the pointer and every other answer to input is drawn
at once, so the limit cannot be felt in the keyboard.
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
impl FrameLimit
Sourcepub const LOCAL: u32 = 60
pub const LOCAL: u32 = 60
Frames a second the default draws locally: as many as a screen at 60 Hz shows.
Sourcepub const REMOTE: u32 = 20
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.
Sourcepub fn per_second(frames: u32) -> Self
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.
Sourcepub fn remote(self, frames: u32) -> Self
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.
Sourcepub fn frames_per_second(self, remote: bool) -> Option<u32>
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
impl Clone for FrameLimit
Source§fn clone(&self) -> FrameLimit
fn clone(&self) -> FrameLimit
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for FrameLimit
Source§impl Debug for FrameLimit
impl Debug for FrameLimit
Source§impl Default for FrameLimit
impl Default for FrameLimit
impl Eq for FrameLimit
Source§impl PartialEq for FrameLimit
impl PartialEq for FrameLimit
impl StructuralPartialEq for FrameLimit
Auto Trait Implementations§
impl Freeze for FrameLimit
impl RefUnwindSafe for FrameLimit
impl Send for FrameLimit
impl Sync for FrameLimit
impl Unpin for FrameLimit
impl UnsafeUnpin for FrameLimit
impl UnwindSafe for FrameLimit
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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