code: def to_frame(self, data, state):
          
  
          # First, determine the length we're looking for
          length = state.length
          if length is None:
              # Try decoding a length from the data buffer
              length = self.decode_length(data, state)
  
          # Now, is there enough data?
          if len(data) < length:
              state.length = length
              raise exc.NoFrames()
  
          # Extract the frame
          frame = six.binary_type(data[:length])
          del data[:length]
  
          # Update the state
          state.length = None
  
          # Return the frame
          return frame
docs: Extract a single frame from the data buffer.  The consumed
          data should be removed from the buffer.  If no complete frame
          can be read, must raise a ``NoFrames`` exception.
  
          :param data: A ``bytearray`` instance containing the data so
                       far read.
          :param state: An instance of ``FramerState``.  If the buffer
                        contains a partial frame, this object can be
                        used to store state information to allow the
                        remainder of the frame to be read.
  
          :returns: A frame.  The frame may be any object.  The stock
                    framers always return bytes.