ScrapedItem

Trait ScrapedItem 

Source
pub trait ScrapedItem:
    Debug
    + Send
    + Sync
    + Any
    + 'static {
    // Required methods
    fn as_any(&self) -> &(dyn Any + 'static);
    fn box_clone(&self) -> Box<dyn ScrapedItem + Sync + Send>;
    fn to_json_value(&self) -> Value;

    // Provided methods
    fn item_schema(&self) -> Option<ItemSchema> { ... }
    fn item_schema_version(&self) -> u32 { ... }
}
Expand description

Parse-time output sink and item contracts used by Spider::parse. Trait implemented by item types emitted from spiders.

In normal application code you usually do not implement this trait by hand. Prefer annotating the item struct with #[scraped_item], which wires up the required serialization and cloning behavior automatically.

Required Methods§

Source

fn as_any(&self) -> &(dyn Any + 'static)

Returns the item as a dyn Any for downcasting.

Source

fn box_clone(&self) -> Box<dyn ScrapedItem + Sync + Send>

Clones the item into a Box<dyn ScrapedItem>.

Source

fn to_json_value(&self) -> Value

Converts the item to a serde_json::Value.

Provided Methods§

Source

fn item_schema(&self) -> Option<ItemSchema>

Returns typed schema metadata when the item type exposes it.

Source

fn item_schema_version(&self) -> u32

Returns the schema version used by this item.

Trait Implementations§

Source§

impl Clone for Box<dyn ScrapedItem + Sync + Send>

Source§

fn clone(&self) -> Box<dyn ScrapedItem + Sync + Send>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Implementors§