MCPcopy Create free account
hub / github.com/LEXUGE/dcompass / worker

Function worker

dcompass/src/worker.rs:25–51  ·  view source on GitHub ↗

Handle a single incoming packet

(
    router: Arc<Router<RuneScript>>,
    socket: Arc<UdpSocket>,
    buf: Bytes,
    src: SocketAddr,
)

Source from the content-addressed store, hash-verified

23
24/// Handle a single incoming packet
25pub async fn worker(
26 router: Arc<Router<RuneScript>>,
27 socket: Arc<UdpSocket>,
28 buf: Bytes,
29 src: SocketAddr,
30) -> Result<()> {
31 socket
32 .send_to(
33 router
34 .resolve(
35 Message::from_octets(buf)?,
36 Some(QueryContext { ip: src.ip() }),
37 )
38 .await?
39 .as_slice(),
40 src,
41 )
42 .await
43 .unwrap_or_else(|e| {
44 warn!("failed to send back response: {}", e);
45 0
46 });
47
48 info!("response completed. Sent back to {} successfully.", src);
49
50 Ok(())
51}

Callers

nothing calls this directly

Calls 1

resolveMethod · 0.45

Tested by

no test coverage detected