ProtocolAdapter

Trait ProtocolAdapter 

Source
pub trait ProtocolAdapter: Send + Sync {
    // Required methods
    fn accept_connection<'life0, 'async_trait>(
        &'life0 self,
        stream: TcpStream,
    ) -> Pin<Box<dyn Future<Output = NirvResult<Connection>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn authenticate<'life0, 'life1, 'async_trait>(
        &'life0 self,
        conn: &'life1 mut Connection,
        credentials: Credentials,
    ) -> Pin<Box<dyn Future<Output = NirvResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn handle_query<'life0, 'life1, 'async_trait>(
        &'life0 self,
        conn: &'life1 Connection,
        query: ProtocolQuery,
    ) -> Pin<Box<dyn Future<Output = NirvResult<ProtocolResponse>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_protocol_type(&self) -> ProtocolType;
    fn parse_message<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        conn: &'life1 Connection,
        data: &'life2 [u8],
    ) -> Pin<Box<dyn Future<Output = NirvResult<ProtocolQuery>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn format_response<'life0, 'life1, 'async_trait>(
        &'life0 self,
        conn: &'life1 Connection,
        result: QueryResult,
    ) -> Pin<Box<dyn Future<Output = NirvResult<Vec<u8>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn terminate_connection<'life0, 'life1, 'async_trait>(
        &'life0 self,
        conn: &'life1 mut Connection,
    ) -> Pin<Box<dyn Future<Output = NirvResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Main trait for database protocol adapters

Required Methods§

Source

fn accept_connection<'life0, 'async_trait>( &'life0 self, stream: TcpStream, ) -> Pin<Box<dyn Future<Output = NirvResult<Connection>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Accept a new connection and perform initial handshake

Source

fn authenticate<'life0, 'life1, 'async_trait>( &'life0 self, conn: &'life1 mut Connection, credentials: Credentials, ) -> Pin<Box<dyn Future<Output = NirvResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Authenticate a connection with provided credentials

Source

fn handle_query<'life0, 'life1, 'async_trait>( &'life0 self, conn: &'life1 Connection, query: ProtocolQuery, ) -> Pin<Box<dyn Future<Output = NirvResult<ProtocolResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Handle a query from the client and return a response

Source

fn get_protocol_type(&self) -> ProtocolType

Get the protocol type this adapter handles

Source

fn parse_message<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, conn: &'life1 Connection, data: &'life2 [u8], ) -> Pin<Box<dyn Future<Output = NirvResult<ProtocolQuery>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Parse protocol-specific message into internal representation

Source

fn format_response<'life0, 'life1, 'async_trait>( &'life0 self, conn: &'life1 Connection, result: QueryResult, ) -> Pin<Box<dyn Future<Output = NirvResult<Vec<u8>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Format internal query result into protocol-specific response

Source

fn terminate_connection<'life0, 'life1, 'async_trait>( &'life0 self, conn: &'life1 mut Connection, ) -> Pin<Box<dyn Future<Output = NirvResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Handle connection termination

Implementors§