You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: manager.rs
    path of file: ./repos/SquireCore/squire_sdk/src/sync
    
    the code of the file until where you have to start completion: use std::ops::Deref;

use serde::{Deserialize, Serialize};
use squire_lib::{
    accounts::SquireAccount,
    tournament::{Tournament, TournamentSeed},
};

use super::{processor::SyncCompletion, OpId, OpLog, SyncError};
#[cfg(feature = "server")]
use crate::sync::{processor::SyncDecision, ServerOpLink};
#[cfg(feature = "client")]
use crate::{
    model::operations::TournOp,
    sync::{error::ForwardError, SyncForwardResp},
};
#[cfg(any(feature = "client", feature = "server"))]
use crate::{
    model::operations::{OpData, OpResult},
    sync::{processor::SyncProcessor, FullOp, OpSync},
};

/// A state manager for the tournament struct
///
/// The manager holds the current tournament and can recreate any meaningful prior state.
///
/// This is the primary synchronization primative between tournaments.
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
pub struct TournamentManager {
    tourn: Tournament,
    log: OpLog,
    /// The last OpId of the last operation after a successful sync
    last_sync: Option<OpId>,
}

impl TournamentManager {
    /// Creates a tournament manager, tournament, and operations log
    pub fn new(owner: SquireAccount, seed: TournamentSeed) -> Self {
        let log = OpLog::new(owner, seed);
        let tourn = log.init_tourn();
        Self {
            tourn,
            log,
            last_sync: None,
        }
    }

    /// Read only accesses to tournaments don't need to be wrapped, so we can freely provide
    /// references to them
    pub fn tourn(&self) -> &Tournament {
        &self.tourn
    }

    /// Takes the manager, removes all unnecessary data for storage, and return the underlying
    /// tournament, consuming the manager in the process.
    pub fn extract(self) -> Tournament {
        self.tourn
    }

    #[cfg(any(feature = "server", feature = "client"))]
    fn bulk_apply_ops_inner<I>(&mut self, mut ops: I) -> OpResult
    where
        I: ExactSizeIterator<Item = FullOp>,
    {
        let mut buffer = self.tourn().clone();
        let mut f_ops = Vec::with_capacity(ops.len());
    
    
    pub fn handle_forwarded_sync(&mut self, sync: OpSync) -> SyncForwardResp {
        let Ok(anchor_id) = sync.first_id() else {
            return SyncForwardResp::Aborted;
        };

        // Ensure the following holds:
        //  Log : known ops | anchor op | common ops
        //  Sync:             anchor op | common ops | new ops
        //
        //  I.e. we don't want the sync to be of the form:
        //  Log : known ops | anchor op | common ops
        //  Sync:             anchor op | new ops    | common ops
        //
        //  Note that the proc divides the sync at the first unknown operation. A well formed proc
        //  should look like this:
        //  Sync           : anchor op | common ops | new ops
        //  Proc known     : anchor op | common ops
        //  Proc to_process: new ops
        //
        //  And a problematic proc will like this:
        //  Sync           : anchor op | common ops | new op | a mix of common and new ops
        //  Proc known     : anchor op | common ops |
        //  Proc to_process: new op    | a mix of common and new ops
        if let Some(iter) = self.log.iter_passed_op(anchor_id) {
            if iter.zip(sync.ops.iter().skip(1)).any(|(a, b)| a != b) {
                return SyncForwardResp::Aborted;
            }
        }
        let proc = match SyncProcessor::new(sync, &self.log) {
            Ok(proc) => proc,
            Err(err) => {
                return match err {
                    SyncError::UnknownOperation(_) | SyncError::TournUpdated => {
                        SyncForwardResp::Aborted
                    }
                    SyncError::EmptySync => ForwardError::EmptySync.into(),
                    SyncError::InvalidRequest(err) => (*err).into(),
                    // TODO: Figure out what to do here... They shouldn't happen
                    SyncError::NotInitialized => todo!(),
                    SyncError::AlreadyInitialized => todo!(),
                    SyncError::AlreadyCompleted => todo!(),
                    SyncError::Unauthorized => todo!(),
                    SyncError::InvalidReply => todo!(),
                };
            }
        };

        match self.bulk_apply_ops_inner(proc.to_process.into_iter()) {
            Err(err) => err.into(),
            Ok(_) => {
                self.last_sync = self.log.last_id();
                SyncForwardResp::Success
            }
        }
    }