pub fn spin_new(&self, name: String) -> Result<Beat> {

        // Verify input data
        if name.len() == 0 {
            return Err(TE::RegisterFail ("Error: Incorrect register data"))
        }

        // Make a registration call and create a new Beat with the returned id
        // and a cloned copy of the runtime call sender. For pings.
        if let Err(e) = self.rt_tx.send(DM2Deck::Registration(name)) {
            Err(TE::DM2DeckSendFail(e))
        } else {
            // WARNING: What if the deck never returns a response?
            // TODO: Timeout?
            match self.rt_rx.recv() {
                Ok(DM2DJ::ID(Ok(id))) => {
                    Ok(Beat{id, sender: self.rt_tx.clone()})
                },
                Ok(DM2DJ::ID(Err(e))) => Err(e),
                Err(e) => Err(TE::ChannelRecvFail(e)),
                _ => Err(TE::MaximumConfusion),
            } 
        }
    }
// Add a record to the record map and return an assoiciated Beat struct
Add a record to the record map and return an assoiciated Beat struct
Add a record to the record map and return an assoiciated Beat struct
pub fn spin_new(&self, name: String) -> Result<Beat> {
        // Verify input data
        if name.len() == 0 {
            return Err(TE::RegisterFail ("Error: Incorrect register data"))
        }
        // Make a registration call and create a new Beat with the returned id
        // and a cloned copy of the runtime call sender. For pings.
        if let Err(e) = self.rt_tx.send(DM2Deck::Registration(name)) {
            Err(TE::DM2DeckSendFail(e))
        } else {
            // WARNING: What if the deck never returns a response?
            // TODO: Timeout?
            match self.rt_rx.recv() {
                Ok(DM2DJ::ID(Ok(id))) => {
                    Ok(Beat{id, sender: self.rt_tx.clone()})
                },
                Ok(DM2DJ::ID(Err(e))) => Err(e),
                Err(e) => Err(TE::ChannelRecvFail(e)),
                _ => Err(TE::MaximumConfusion),
            } 
        }
    }
pub fn spin_new ( & self , name : String ) -> Result < Beat > { // Verify input data if name . len ( ) == 0 { return Err ( TE :: RegisterFail ( " " ) ) } // Make a registration call and create a new Beat with the returned id // and a cloned copy of the runtime call sender. For pings. if let Err ( e ) = self . rt_tx . send ( DM2Deck :: Registration ( name ) ) { Err ( TE :: DM2DeckSendFail ( e ) ) } else { // WARNING: What if the deck never returns a response? // TODO: Timeout? match self . rt_rx . recv ( ) { Ok ( DM2DJ :: ID ( Ok ( id ) ) ) => { Ok ( Beat { id , sender : self . rt_tx . clone ( ) } ) } , Ok ( DM2DJ :: ID ( Err ( e ) ) ) => Err ( e ) , Err ( e ) => Err ( TE :: ChannelRecvFail ( e ) ) , _ => Err ( TE :: MaximumConfusion ) , } } }
Add a record to the record map and return an assoiciated Beat struct
Add a record to the record map and return an assoiciated Beat struct
&self
name
String
&self
name
String