Skip to main content

RepeaterHandle

Struct RepeaterHandle 

Source
pub struct RepeaterHandle<E>
where E: RepeaterEntry + Clone + Unpin + 'static,
{ /* private fields */ }
Expand description

Used to communicate with the repeater task

Returned after the call to Repeater::run_with_async_callback

Implementations§

Source§

impl<E> RepeaterHandle<E>
where E: RepeaterEntry + Clone + Unpin + 'static,

Source

pub async fn insert(&self, e: E) -> Result<(), ConnectionLost>

Insert entry into Repeater

Examples found in repository?
examples/simple.rs (line 44)
32async fn main() {
33    let callback = |entry, _| async move { println!("Popped {entry:?}") };
34
35    // create and start the repeater
36    let handle = async_repeater::Repeater::with_capacity(25).run_with_async_callback(callback);
37
38    // create entries with the same interval
39    let dur = Duration::from_secs(5);
40    let repetition = vec![Entry::new(0, dur), Entry::new(1, dur), Entry::new(2, dur)];
41
42    // insert the entries into the repeater with 1 second delay in between
43    for repetition in repetition {
44        handle.insert(repetition).await.unwrap();
45        tokio::time::sleep(Duration::from_secs(1)).await;
46    }
47
48    // wait for a ctrl-c.
49    // If this wasn't there, the program would exit immidiatly without running
50    // a single repetition
51    tokio::signal::ctrl_c().await.unwrap();
52    handle.stop().await.unwrap();
53    println!("Stopping cycler");
54}
Source

pub async fn remove(&self, key: E::Key) -> Result<(), ConnectionLost>

Remove entry from Repeater

Source

pub async fn clear(&self) -> Result<(), ConnectionLost>

Remove all entries from Repeater

Source

pub async fn stop(self) -> Result<(), ConnectionLost>

Stop a Repeater

Examples found in repository?
examples/simple.rs (line 52)
32async fn main() {
33    let callback = |entry, _| async move { println!("Popped {entry:?}") };
34
35    // create and start the repeater
36    let handle = async_repeater::Repeater::with_capacity(25).run_with_async_callback(callback);
37
38    // create entries with the same interval
39    let dur = Duration::from_secs(5);
40    let repetition = vec![Entry::new(0, dur), Entry::new(1, dur), Entry::new(2, dur)];
41
42    // insert the entries into the repeater with 1 second delay in between
43    for repetition in repetition {
44        handle.insert(repetition).await.unwrap();
45        tokio::time::sleep(Duration::from_secs(1)).await;
46    }
47
48    // wait for a ctrl-c.
49    // If this wasn't there, the program would exit immidiatly without running
50    // a single repetition
51    tokio::signal::ctrl_c().await.unwrap();
52    handle.stop().await.unwrap();
53    println!("Stopping cycler");
54}
Source

pub async fn len(self) -> Result<usize, ConnectionLost>

Return the number of entries in Repeater

Source

pub async fn is_empty(self) -> Result<bool, ConnectionLost>

Return true if no entries are inside of Repeater

Trait Implementations§

Source§

impl<E> Clone for RepeaterHandle<E>
where E: RepeaterEntry + Clone + Unpin + 'static + Clone,

Source§

fn clone(&self) -> RepeaterHandle<E>

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<E> Debug for RepeaterHandle<E>
where E: RepeaterEntry + Clone + Unpin + 'static + Debug,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<E> Freeze for RepeaterHandle<E>

§

impl<E> RefUnwindSafe for RepeaterHandle<E>

§

impl<E> Send for RepeaterHandle<E>
where E: Send,

§

impl<E> Sync for RepeaterHandle<E>
where E: Send,

§

impl<E> Unpin for RepeaterHandle<E>

§

impl<E> UnsafeUnpin for RepeaterHandle<E>

§

impl<E> UnwindSafe for RepeaterHandle<E>

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<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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.