pub struct Server {
listener: Listener<Value, Error>,
task_group: TaskGroup,
config: ServerConfig,
}
Expand description
Represents an RPC server
Fields§
§listener: Listener<Value, Error>
§task_group: TaskGroup
§config: ServerConfig
Implementations§
Source§impl Server
impl Server
Sourcepub fn start(self: Arc<Self>)
pub fn start(self: Arc<Self>)
Starts the RPC server by spawning a new task for the main accept loop. The accept loop listens for incoming connections.
This function does not block the current thread. If you need the thread to block,
use the [start_block
] method instead.
Sourcepub async fn start_block(self: Arc<Self>) -> Result<()>
pub async fn start_block(self: Arc<Self>) -> Result<()>
Starts the RPC server by running the main accept loop. The accept loop listens for incoming connections and blocks the current thread.
If you prefer a non-blocking implementation, use the [start
] method instead.
async fn accept_loop(self: &Arc<Self>) -> Result<()>
Sourcepub fn local_endpoint(&self) -> Result<Endpoint>
pub fn local_endpoint(&self) -> Result<Endpoint>
Returns the local endpoint.
Sourceasync fn handle_conn(self: &Arc<Self>, conn: Conn<Value, Error>) -> Result<()>
async fn handle_conn(self: &Arc<Self>, conn: Conn<Value, Error>) -> Result<()>
Handles a new connection
fn sanity_check(&self, request: Value) -> SanityCheckResult
Sourceasync fn new_request(
self: &Arc<Self>,
queue: Arc<ResponseQueue<Value>>,
channel: Arc<Channel>,
msg: Value,
)
async fn new_request( self: &Arc<Self>, queue: Arc<ResponseQueue<Value>>, channel: Arc<Channel>, msg: Value, )
Spawns a new task for handling the new request
Sourceasync fn handle_request(&self, channel: Arc<Channel>, msg: Value) -> Response
async fn handle_request(&self, channel: Arc<Channel>, msg: Value) -> Response
Handles the new request, and returns an RPC Response that has either an error or result
Sourceasync fn init(
config: ServerConfig,
ex: Option<Executor>,
codec: impl ClonableJsonCodec + 'static,
) -> Result<Arc<Self>>
async fn init( config: ServerConfig, ex: Option<Executor>, codec: impl ClonableJsonCodec + 'static, ) -> Result<Arc<Self>>
Initializes a new Server
from the provided ServerConfig
async fn listen( config: &ServerConfig, codec: impl ClonableJsonCodec + 'static, ) -> Result<Listener<Value, Error>>
Auto Trait Implementations§
impl !Freeze for Server
impl !RefUnwindSafe for Server
impl Send for Server
impl Sync for Server
impl Unpin for Server
impl !UnwindSafe for Server
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more