pub struct Searcher { /* private fields */ }Expand description
Searcher to search cubes.
Implementations§
Source§impl Searcher
impl Searcher
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new searcher instance.
The default search timeout is 3 seconds.
Use [Searcher::new_with_timeout][] to specify custom timeout.
Sourcepub async fn all(&mut self) -> Result<Vec<Cube>>
pub async fn all(&mut self) -> Result<Vec<Cube>>
Searches for all cubes.
This searches for cubes for 3 seconds.
Use Searcher::all_timeout to use custom timeout.
Sourcepub async fn nearest(&mut self) -> Result<Cube>
pub async fn nearest(&mut self) -> Result<Cube>
Finds the nearest cube.
This searches for cubes for 3 seconds.
Use Searcher::nearest_timeout to use custom timeout.
Sourcepub async fn all_timeout(&mut self, timeout: Duration) -> Result<Vec<Cube>>
pub async fn all_timeout(&mut self, timeout: Duration) -> Result<Vec<Cube>>
Searches for all cubes with custom timeout.
Cubes are sorted from nearest to farest.
use std::time::Duration;
use toio::Cube;
#[tokio::main]
async fn main() {
let cubes = Cube::search().all_timeout(Duration::from_secs(8)).await.unwrap();
}Sourcepub async fn nearest_timeout(&mut self, timeout: Duration) -> Result<Cube>
pub async fn nearest_timeout(&mut self, timeout: Duration) -> Result<Cube>
Finds the nearest cube with custom timeout.
use std::time::Duration;
use toio::Cube;
#[tokio::main]
async fn main() {
let cube = Cube::search().nearest_timeout(Duration::from_secs(8)).await.unwrap();
}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Searcher
impl !RefUnwindSafe for Searcher
impl Send for Searcher
impl !Sync for Searcher
impl Unpin for Searcher
impl !UnwindSafe for Searcher
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
Mutably borrows from an owned value. Read more