pub fn write_call(&mut self, dst: &mut [u8], name: &str) -> Result<usize, &'static str> {
        let mut written: usize = 0;

        while let Some(state) = self.stack.last_mut() {
            match state {
                States::Init => {
                    let cnt = write_magic(CALL_ID, &mut self.source.buffer).unwrap();
                    self.source.prepare(cnt);
                    *state = States::CallHead;
                }
                States::CallHead => {
                    written += self.source.flush(dst, written);
                    if !self.source.is_empty() {
                        return Ok(written);
                    }
                    if name.len() > 255 {
                        return Err("method name too long");
                    }
                    if written == dst.len() {
                        return Ok(written);
                    }

                    // prepare method name lenght in the buffer
                    dst[written] = name.len() as u8;
                    written += 1;
                    self.source.prepare(name.len());
                    *state = States::CallMethod;
                }
                States::CallMethod => {
                    written += Serializer::copy_next_chunk(
                        dst,
                        written,
                        &mut self.source,
                        &name.as_bytes(),
                    );
                    *state = States::StackPop;
                }
                States::StackPop => {
                    self.stack.pop();
                }
                _ => return Err("Invalid state"),
            }
        }
        Ok(written)
    }
// create FRPC/S method call with method name.
create FRPC/S method call with method name.
create FRPC / S method call with method name .
pub fn write_call(&mut self, dst: &mut [u8], name: &str) -> Result<usize, &'static str> {
        let mut written: usize = 0;
        while let Some(state) = self.stack.last_mut() {
            match state {
                States::Init => {
                    let cnt = write_magic(CALL_ID, &mut self.source.buffer).unwrap();
                    self.source.prepare(cnt);
                    *state = States::CallHead;
                }
                States::CallHead => {
                    written += self.source.flush(dst, written);
                    if !self.source.is_empty() {
                        return Ok(written);
                    }
                    if name.len() > 255 {
                        return Err("method name too long");
                    }
                    if written == dst.len() {
                        return Ok(written);
                    }
                    // prepare method name lenght in the buffer
                    dst[written] = name.len() as u8;
                    written += 1;
                    self.source.prepare(name.len());
                    *state = States::CallMethod;
                }
                States::CallMethod => {
                    written += Serializer::copy_next_chunk(
                        dst,
                        written,
                        &mut self.source,
                        &name.as_bytes(),
                    );
                    *state = States::StackPop;
                }
                States::StackPop => {
                    self.stack.pop();
                }
                _ => return Err("Invalid state"),
            }
        }
        Ok(written)
    }
pub fn write_call ( & mut self , dst : & mut [ u8 ] , name : & str ) -> Result < usize , & ' static str > { let mut written : usize = 0 ; while let Some ( state ) = self . stack . last_mut ( ) { match state { States :: Init => { let cnt = write_magic ( CALL_ID , & mut self . source . buffer ) . unwrap ( ) ; self . source . prepare ( cnt ) ; * state = States :: CallHead ; } States :: CallHead => { written += self . source . flush ( dst , written ) ; if ! self . source . is_empty ( ) { return Ok ( written ) ; } if name . len ( ) > 255 { return Err ( " " ) ; } if written == dst . len ( ) { return Ok ( written ) ; } // prepare method name lenght in the buffer dst [ written ] = name . len ( ) as u8 ; written += 1 ; self . source . prepare ( name . len ( ) ) ; * state = States :: CallMethod ; } States :: CallMethod => { written += Serializer :: copy_next_chunk ( dst , written , & mut self . source , & name . as_bytes ( ) , ) ; * state = States :: StackPop ; } States :: StackPop => { self . stack . pop ( ) ; } _ => return Err ( " " ) , } } Ok ( written ) }
create FRPC/S method call with method name.
create FRPC / S method call with method name .
&mut self
dst
&mut [u8]
name
&str
&mut self
dst
&mut [u8]
name
&str