1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
//! This module contains [`TransformEntry`](`entry::TransformEntry`) and [`TransformField`](`field::TransformField`) traits as well as all types that implement it
pub mod entry;
pub mod field;
pub mod result;
pub mod error;
pub use self::{
entry::{feed::Feed, html::Html, http::Http, json::Json, print::DebugPrint, use_as::Use},
field::{caps::Caps, set::Set, shorten::Shorten, trim::Trim},
};
use self::error::TransformError;
use crate::entry::Entry;
use async_trait::async_trait;
use std::fmt::Debug;
/// Transform an [`Entry`] into one or more new (entries)[`Entry`].
///
/// For example, a [`Json`] transform parses the contents of the [`Entry`] as JSON and returns new entries from it,
/// while the [`Caps`] field transform just makes a field uppercase
#[async_trait]
pub trait Transform: Debug + Send + Sync {
/// Transform an [`Entry`] to one or more entries
///
/// # Erorrs
/// Refer to implementators docs
async fn transform(&self, entry: Entry) -> Result<Vec<Entry>, TransformError>;
}