Expand description
§spider-macro
Provides procedural macros for the spider-lib framework to reduce boilerplate code.
§Overview
The spider-macro crate contains procedural macros that automate the
implementation of common traits and patterns used in the spider framework.
These macros significantly reduce the amount of boilerplate code required
when defining custom data structures for scraped items.
§Key Macros
#[scraped_item]: Derives theScrapedItemtrait along with necessary implementations for serialization, deserialization, cloning, and type conversions. This macro automatically implements all required traits for a struct to be used as a scraped item in the framework.
§Features
- Automatic Trait Derivation: Implements
Serialize,Deserialize,Clone, andDebugtraits automatically - ScrapedItem Implementation: Provides the complete implementation of
the
ScrapedItemtrait required by the framework - Type Safety: Maintains type safety while reducing boilerplate
- Performance: Generates efficient code without runtime overhead
§Example
ⓘ
use spider_macro::scraped_item;
#[scraped_item]
struct Article {
title: String,
content: String,
author: String,
published_date: String,
}
// The macro generates all necessary implementations automatically
// including serialization, deserialization, and the ScrapedItem traitAttribute Macros§
- scraped_
item - A procedural macro to derive the
ScrapedItemtrait.