pub struct Item {
pub kind: &'static str,
pub id: String,
pub fields: Vec<(&'static str, String)>,
pub found_by: Vec<(String, SearchWeight)>,
pub body: Option<SearchBody>,
pub payload: Option<Arc<dyn Any + Send + Sync>>,
}Expand description
One item of a resource type, as search and views read it: its type, its
id, and its fields by key. A field may hold several values (a song by two
artists). A remote source attaches what it fetched (payload), so the app
can make the item playable or openable before anything is stored.
Fields§
§kind: &'static str§id: String§fields: Vec<(&'static str, String)>§found_by: Vec<(String, SearchWeight)>More text the item is found by but that no presentation shows, each ranked by its own weight: a book’s subject, a note on a highlight.
body: Option<SearchBody>Long prose the item is found by (a book’s chapter), read in place. A match in a segment the body locates is a hit of its own: its location, listed under the location’s own type.
payload: Option<Arc<dyn Any + Send + Sync>>Implementations§
Source§impl Item
impl Item
pub fn new(kind: &'static str, id: impl Into<String>) -> Self
Sourcepub fn from_entry(kinds: &[KindDecl], entry: &SearchEntry) -> Option<Self>
pub fn from_entry(kinds: &[KindDecl], entry: &SearchEntry) -> Option<Self>
The item an app’s search entry describes, typed by the declaration
whose plural names the entry’s group (an entry without a group is
the first type’s): its title and subtitle fill the type’s title and
subtitle fields, its facets the filter fields of the same keys, and
its fields and body are what it is found by. The entry rides along
as the payload, so opening the item invokes what the entry does.
None when no type is the entry’s or it addresses nothing.
Sourcepub fn with(self, key: &'static str, value: impl Into<String>) -> Self
pub fn with(self, key: &'static str, value: impl Into<String>) -> Self
Add value to the field key; an empty value adds nothing.
Sourcepub fn payload(self, payload: Arc<dyn Any + Send + Sync>) -> Self
pub fn payload(self, payload: Arc<dyn Any + Send + Sync>) -> Self
Attach what a remote source fetched.
Sourcepub fn values<'a>(&'a self, key: &'a str) -> impl Iterator<Item = &'a str> + 'a
pub fn values<'a>(&'a self, key: &'a str) -> impl Iterator<Item = &'a str> + 'a
Every value of the field key.
Sourcepub fn key(&self) -> (&'static str, &str)
pub fn key(&self) -> (&'static str, &str)
What identifies the item across sources: its type and id.
Sourcepub fn entry(&self) -> Option<&SearchEntry>
pub fn entry(&self) -> Option<&SearchEntry>
The search entry the item was made from (Item::from_entry).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Item
impl !RefUnwindSafe for Item
impl Send for Item
impl Sync for Item
impl Unpin for Item
impl UnsafeUnpin for Item
impl !UnwindSafe for Item
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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