// Convenient function to handle an AnnotationControllerRequest.
Convenient function to handle an AnnotationControllerRequest.
Convenient function to handle an AnnotationControllerRequest .
fn handle_annotation_controller_request(
    annotations: &mut AnnotationHolder,
    watch_subscriber: &mut WatchSubscriber,
    request: felement::AnnotationControllerRequest,
) -> Result<(), AnnotationError> {
    match request {
        felement::AnnotationControllerRequest::UpdateAnnotations {
            annotations_to_set,
            annotations_to_delete,
            responder,
        } => {
            let result = annotations.update_annotations(annotations_to_set, annotations_to_delete);
            match result {
                Ok(()) => responder.send(&mut Ok(())),
                Err(AnnotationError::Update(e)) => responder.send(&mut Err(e)),
                Err(_) => unreachable!(),
            }
            .ok();
        }
        felement::AnnotationControllerRequest::GetAnnotations { responder } => {
            let result = annotations.get_annotations();
            match result {
                Ok(annotation_vec) => responder.send(&mut Ok(annotation_vec)),
                Err(AnnotationError::Get(e)) => responder.send(&mut Err(e)),
                Err(_) => unreachable!(),
            }
            .ok();
        }
        felement::AnnotationControllerRequest::WatchAnnotations { responder } => {
            // An error is returned if there is already a `WatchAnnotations` request pending for the client. Since the responder gets dropped (TODO(fxbug.dev/94602)), the connection will be closed to indicate unexpected client behavior.
            watch_subscriber.watch_annotations(WatchResponder::AnnotationController(responder))?;
        }
    }
    Ok(())
}
fn handle_annotation_controller_request ( annotations : & mut AnnotationHolder , watch_subscriber : & mut WatchSubscriber , request : felement :: AnnotationControllerRequest , ) -> Result < ( ) , AnnotationError > { match request { felement :: AnnotationControllerRequest :: UpdateAnnotations { annotations_to_set , annotations_to_delete , responder , } => { let result = annotations . update_annotations ( annotations_to_set , annotations_to_delete ) ; match result { Ok ( ( ) ) => responder . send ( & mut Ok ( ( ) ) ) , Err ( AnnotationError :: Update ( e ) ) => responder . send ( & mut Err ( e ) ) , Err ( _ ) => unreachable ! ( ) , } . ok ( ) ; } felement :: AnnotationControllerRequest :: GetAnnotations { responder } => { let result = annotations . get_annotations ( ) ; match result { Ok ( annotation_vec ) => responder . send ( & mut Ok ( annotation_vec ) ) , Err ( AnnotationError :: Get ( e ) ) => responder . send ( & mut Err ( e ) ) , Err ( _ ) => unreachable ! ( ) , } . ok ( ) ; } felement :: AnnotationControllerRequest :: WatchAnnotations { responder } => { // An error is returned if there is already a `WatchAnnotations` request pending for the client. Since the responder gets dropped (TODO(fxbug.dev/94602)), the connection will be closed to indicate unexpected client behavior. watch_subscriber . watch_annotations ( WatchResponder :: AnnotationController ( responder ) ) ? ; } } Ok ( ( ) ) }
Convenient function to handle an AnnotationControllerRequest.
Convenient function to handle an AnnotationControllerRequest .
annotations
&mut AnnotationHolder
watch_subscriber
&mut WatchSubscriber
request
felement::AnnotationControllerRequest