Skip to main content

EvalSite

Trait EvalSite 

Source
pub trait EvalSite: Send + Sync {
    // Required methods
    fn site_kind(&self) -> &'static str;
    fn address(&self) -> &ServerAddress;
    fn codecs(&self) -> &[Symbol];
    fn answer(&self, cx: &mut Cx, frame: ServerFrame) -> Result<ServerFrame>;
    fn as_any(&self) -> &dyn Any;

    // Provided methods
    fn answer_with_timeout(
        &self,
        cx: &mut Cx,
        frame: ServerFrame,
        _timeout: Option<Duration>,
    ) -> Result<ServerFrame> { ... }
    fn close_connection(&self, _cx: &mut Cx) -> Result<()> { ... }
    fn stream(
        &self,
        cx: &mut Cx,
        frame: ServerFrame,
        sink: &mut dyn StreamSink,
    ) -> Result<()> { ... }
    fn as_eval_fabric(&self) -> Option<&dyn EvalFabric> { ... }
}
Expand description

A request-answering eval endpoint: it accepts server frames and produces reply frames, optionally streaming or exposing an EvalFabric.

Required Methods§

Source

fn site_kind(&self) -> &'static str

Returns a short label naming the kind of site.

Source

fn address(&self) -> &ServerAddress

Returns the address this site answers at.

Source

fn codecs(&self) -> &[Symbol]

Returns the codecs this site can decode and encode.

Source

fn answer(&self, cx: &mut Cx, frame: ServerFrame) -> Result<ServerFrame>

Answers frame, returning the reply frame.

Source

fn as_any(&self) -> &dyn Any

Returns the site as &dyn Any for downcasting.

Provided Methods§

Source

fn answer_with_timeout( &self, cx: &mut Cx, frame: ServerFrame, _timeout: Option<Duration>, ) -> Result<ServerFrame>

Answers frame with an optional deadline. Defaults to EvalSite::answer.

Source

fn close_connection(&self, _cx: &mut Cx) -> Result<()>

Closes any connection backing the site. Defaults to a no-op.

Source

fn stream( &self, cx: &mut Cx, frame: ServerFrame, sink: &mut dyn StreamSink, ) -> Result<()>

Streams the answer to frame into sink. The default path answers once and emits a single chunk followed by end.

Source

fn as_eval_fabric(&self) -> Option<&dyn EvalFabric>

Returns this site as an EvalFabric when it backs one. Defaults to None.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§