pub fn sync_annotations(
        &self,
        annotations: &[Annotation],
    ) -> color_eyre::Result<(usize, usize)> {
        let (mut added, mut updated) = (0, 0);
        let mut annotation_batch = sled::Batch::default();
        for annotation in annotations {
            let annotation_key = annotation.id.as_bytes();
            if self.annotation_to_tags()?.contains_key(annotation_key)? {
                self.delete_annotation(&annotation.id)?;
                self.add_annotation(annotation, &mut annotation_batch)?;
                updated += 1;
            } else {
                self.add_annotation(annotation, &mut annotation_batch)?;
                added += 1;
            }
        }
        self.annotation_to_tags()?.apply_batch(annotation_batch)?;
        Ok((added, updated))
    }
/// add or update annotations from the Hypothesis API
add or update annotations from the Hypothesis API
add or update annotations from the Hypothesis API
pub fn sync_annotations(
        &self,
        annotations: &[Annotation],
    ) -> color_eyre::Result<(usize, usize)> {
        let (mut added, mut updated) = (0, 0);
        let mut annotation_batch = sled::Batch::default();
        for annotation in annotations {
            let annotation_key = annotation.id.as_bytes();
            if self.annotation_to_tags()?.contains_key(annotation_key)? {
                self.delete_annotation(&annotation.id)?;
                self.add_annotation(annotation, &mut annotation_batch)?;
                updated += 1;
            } else {
                self.add_annotation(annotation, &mut annotation_batch)?;
                added += 1;
            }
        }
        self.annotation_to_tags()?.apply_batch(annotation_batch)?;
        Ok((added, updated))
    }
pub fn sync_annotations ( & self , annotations : & [ Annotation ] , ) -> color_eyre :: Result < ( usize , usize ) > { let ( mut added , mut updated ) = ( 0 , 0 ) ; let mut annotation_batch = sled :: Batch :: default ( ) ; for annotation in annotations { let annotation_key = annotation . id . as_bytes ( ) ; if self . annotation_to_tags ( ) ? . contains_key ( annotation_key ) ? { self . delete_annotation ( & annotation . id ) ? ; self . add_annotation ( annotation , & mut annotation_batch ) ? ; updated += 1 ; } else { self . add_annotation ( annotation , & mut annotation_batch ) ? ; added += 1 ; } } self . annotation_to_tags ( ) ? . apply_batch ( annotation_batch ) ? ; Ok ( ( added , updated ) ) }
add or update annotations from the Hypothesis API
add or update annotations from the Hypothesis API
&self
annotations
&[Annotation]
&self
annotations
&[Annotation]