ed-journals 0.13.0

Provides models for representing and parsing elite dangerous journal files
Documentation
use crate::fs::traits::unblocker::Unblocker;
use crate::fs::{BlockResult, LogFSError};
use std::sync::mpsc::Sender;

/// Unblocks the associated [SyncBlocker](crate::fs::SyncBlocker) by sending a message to the
/// associated channel.
#[derive(Debug, Clone)]
pub struct SyncUnblocker {
    inner: Sender<BlockResult>,
}

impl SyncUnblocker {
    /// Creates a new unblocker using the provided sender.
    pub fn new(sender: Sender<BlockResult>) -> Self {
        Self { inner: sender }
    }
}

impl Unblocker for SyncUnblocker {
    fn unblock(&self, result: BlockResult) -> BlockResult {
        self.inner
            .send(result)
            .map_err(|_| LogFSError::FailedToUnblock)?;

        Ok(())
    }
}