use ntex_bytes::{ByteString, Bytes, BytesMut};
use crate::{encoding::DecodeError, types::Message};
pub trait ServiceDef {
const NAME: &'static str;
type Methods;
fn method_by_name(name: &str) -> Option<Self::Methods>;
}
pub trait MethodDef {
const NAME: &'static str;
const PATH: ByteString;
type Input: Message;
type Output: Message;
#[inline]
fn decode(&self, buf: &mut Bytes) -> Result<Self::Input, DecodeError> {
Message::read(buf)
}
#[inline]
fn encode(&self, val: Self::Output, buf: &mut BytesMut) {
val.write(buf);
}
}