pub struct JsonPipeline<I>where
I: ScrapedItem,{ /* private fields */ }Expand description
JSON array output pipeline. A pipeline that writes all scraped items to a single JSON file as a JSON array. Items are collected in a blocking task and written to disk when the pipeline is closed.
Implementations§
Source§impl<I> JsonPipeline<I>where
I: ScrapedItem,
impl<I> JsonPipeline<I>where
I: ScrapedItem,
Sourcepub fn new(
file_path: impl AsRef<Path>,
) -> Result<JsonPipeline<I>, PipelineError>
pub fn new( file_path: impl AsRef<Path>, ) -> Result<JsonPipeline<I>, PipelineError>
Sourcepub fn with_schema_export_config(
self,
config: SchemaExportConfig,
) -> JsonPipeline<I>
pub fn with_schema_export_config( self, config: SchemaExportConfig, ) -> JsonPipeline<I>
Applies typed export mapping before values are written.
Trait Implementations§
Source§impl<I> Pipeline<I> for JsonPipeline<I>where
I: ScrapedItem,
impl<I> Pipeline<I> for JsonPipeline<I>where
I: ScrapedItem,
Source§fn process_item<'life0, 'async_trait>(
&'life0 self,
item: I,
) -> Pin<Box<dyn Future<Output = Result<Option<I>, PipelineError>> + Send + 'async_trait>>where
'life0: 'async_trait,
JsonPipeline<I>: 'async_trait,
fn process_item<'life0, 'async_trait>(
&'life0 self,
item: I,
) -> Pin<Box<dyn Future<Output = Result<Option<I>, PipelineError>> + Send + 'async_trait>>where
'life0: 'async_trait,
JsonPipeline<I>: 'async_trait,
Processes a single scraped item. Read more
Source§fn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), PipelineError>> + Send + 'async_trait>>where
'life0: 'async_trait,
JsonPipeline<I>: 'async_trait,
fn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), PipelineError>> + Send + 'async_trait>>where
'life0: 'async_trait,
JsonPipeline<I>: 'async_trait,
Called when the spider is closing. Read more
Source§fn get_state<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, PipelineError>> + Send + 'async_trait>>where
'life0: 'async_trait,
JsonPipeline<I>: 'async_trait,
fn get_state<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, PipelineError>> + Send + 'async_trait>>where
'life0: 'async_trait,
JsonPipeline<I>: 'async_trait,
Returns the current state of the pipeline as a JSON value. Read more
Source§fn restore_state<'life0, 'async_trait>(
&'life0 self,
state: Value,
) -> Pin<Box<dyn Future<Output = Result<(), PipelineError>> + Send + 'async_trait>>where
'life0: 'async_trait,
JsonPipeline<I>: 'async_trait,
fn restore_state<'life0, 'async_trait>(
&'life0 self,
state: Value,
) -> Pin<Box<dyn Future<Output = Result<(), PipelineError>> + Send + 'async_trait>>where
'life0: 'async_trait,
JsonPipeline<I>: 'async_trait,
Restores the pipeline’s state from a JSON value. Read more
Auto Trait Implementations§
impl<I> Freeze for JsonPipeline<I>
impl<I> !RefUnwindSafe for JsonPipeline<I>
impl<I> Send for JsonPipeline<I>
impl<I> Sync for JsonPipeline<I>
impl<I> Unpin for JsonPipeline<I>where
I: Unpin,
impl<I> !UnwindSafe for JsonPipeline<I>
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