pub struct Remove<'a> { /* private fields */ }
Expand description
Instruction for removing papers from the database.
This struct implements the DatabaseInstruction
trait to provide
paper removal functionality. It handles:
- Paper identification through queries
- Related data cleanup (authors, files)
- Transaction management
- Dry run simulation
Implementations§
Source§impl<'a> Remove<'a>
impl<'a> Remove<'a>
Sourcepub fn from_query(query: Query<'a>) -> Self
pub fn from_query(query: Query<'a>) -> Self
Creates a remove instruction from an existing query.
This method allows any query to be converted into a remove operation, providing maximum flexibility in identifying papers to remove.
§Arguments
query
- The query that identifies papers to remove
§Examples
// Remove papers matching a text search
let query = Query::text("quantum computing");
let remove = Remove::from_query(query);
// Remove papers before a date
use chrono::{DateTime, Utc};
let date = DateTime::parse_from_rfc3339("2020-01-01T00:00:00Z").unwrap().with_timezone(&Utc);
let query = Query::before_date(date);
let remove = Remove::from_query(query);
Sourcepub fn by_source(source: &'a str, identifier: &'a str) -> Self
pub fn by_source(source: &'a str, identifier: &'a str) -> Self
Creates a remove instruction for a specific paper by its source and identifier.
This is a convenience method for the common case of removing a single paper identified by its source system and ID.
§Arguments
source
- The paper’s source system (arXiv, DOI, etc.)identifier
- The source-specific identifier
§Examples
// Remove an arXiv paper
let remove = Remove::by_source("arxiv", "2301.07041");
// Remove a DOI paper
let remove = Remove::by_source("doi", "10.1145/1327452.1327492");
Creates a remove instruction for all papers by a specific author.
This method provides a way to remove all papers associated with a particular author name. It performs partial matching on the name.
§Arguments
name
- The author name to match
§Examples
// Remove all papers by an author
let remove = Remove::by_author("Alice Researcher");
Sourcepub fn dry_run(self) -> Self
pub fn dry_run(self) -> Self
Enables dry run mode for the remove operation.
In dry run mode, the operation will:
- Query papers that would be removed
- Return the list of papers
- Not modify the database
This is useful for:
- Previewing removal operations
- Validating queries
- Testing removal logic
§Examples
// Preview papers that would be removed
let papers = Remove::by_author("Alice Researcher").dry_run().execute(&mut db).await?;
println!("Would remove {} papers", papers.len());
Trait Implementations§
Source§impl DatabaseInstruction for Remove<'_>
impl DatabaseInstruction for Remove<'_>
Source§fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
db: &'life1 mut Database,
) -> Pin<Box<dyn Future<Output = Result<Self::Output>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
db: &'life1 mut Database,
) -> Pin<Box<dyn Future<Output = Result<Self::Output>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Auto Trait Implementations§
impl<'a> Freeze for Remove<'a>
impl<'a> RefUnwindSafe for Remove<'a>
impl<'a> Send for Remove<'a>
impl<'a> Sync for Remove<'a>
impl<'a> Unpin for Remove<'a>
impl<'a> UnwindSafe for Remove<'a>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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