Skip to main content

RemoteSource

Trait RemoteSource 

Source
pub trait RemoteSource:
    Send
    + Sync
    + 'static {
    // Required methods
    fn id(&self) -> &str;
    fn label(&self) -> String;
    fn search(
        &self,
        query: &QuerySpec,
        cancel: &Cancel,
        page: &mut dyn FnMut(Vec<Item>),
    ) -> Result<(), RemoteError>;

    // Provided methods
    fn origin(&self) -> Source { ... }
    fn accepts(&self, query: &QuerySpec) -> bool { ... }
    fn warm(&self) { ... }
}
Expand description

A source of items that are not local: a streaming catalogue, a store, a collaborator’s library. It keeps its own index; nothing of it is downloaded to be searched.

Required Methods§

Source

fn id(&self) -> &str

A stable id, for its cache and its section.

Source

fn label(&self) -> String

What its section is headed (“YouTube Music”).

Source

fn search( &self, query: &QuerySpec, cancel: &Cancel, page: &mut dyn FnMut(Vec<Item>), ) -> Result<(), RemoteError>

Answer query, handing each page of items to page as it arrives, best first. Runs off the UI thread; stop early when cancel says so.

Provided Methods§

Source

fn origin(&self) -> Source

Where its answers come from, as its section’s placeholder names it while one is on the way: a host serving the catalogue by default; a collaborator’s library is a peer.

Source

fn accepts(&self, query: &QuerySpec) -> bool

Whether it answers query at all: a source does not know the person’s own marks (Liked), so a query narrowed by them stays local.

Source

fn warm(&self)

Open the connection before the first query: the person focused the field. Runs off the UI thread.

Implementors§