pub struct Request {
pub seq: i64,
pub command: Command,
}Expand description
Represents a request from a client.
Note that unlike the specification, this implementation does not define a ProtocolMessage base interface. Instead, the only common part (the sequence number) is repeated in the struct.
Specification: Request
Fields§
§seq: i64Sequence number for the Request.
From the specification:
Sequence number of the message (also known as message ID). The seq for
the first message sent by a client or debug adapter is 1, and for each
subsequent message is 1 greater than the previous message sent by that
actor. seq can be used to order requests, responses, and events, and to
associate requests with their corresponding responses. For protocol
messages of type request the sequence number can be used to cancel the
request.
command: CommandThe command to execute.
This is stringly typed in the specification, but represented as an enum for better ergonomics in Rust code, along with the arguments when present.
Implementations§
Source§impl Request
impl Request
Sourcepub fn success(self, body: ResponseBody) -> Response
pub fn success(self, body: ResponseBody) -> Response
Create a successful response for a given request. The sequence number will be copied
from request, message will be None (as its neither cancelled nor an error).
The body argument contains the response itself.
Sourcepub fn error(self, error: &str) -> Response
pub fn error(self, error: &str) -> Response
Create an error response for a given request. The sequence number will be copied
from the request, message will be None (as its neither cancelled nor an error).
§Arguments
req: The request this response corresponds to.body: The body of the response to attach.
Sourcepub fn cancellation(self) -> Response
pub fn cancellation(self) -> Response
Create a cancellation response for the given request. The sequence number will be copied
from the request, message will be ResponseMessage::Cancelled, success will be false,
and body will be None.
Sourcepub fn ack(self) -> Result<Response, ServerError>
pub fn ack(self) -> Result<Response, ServerError>
Create an acknowledgement response. This is a shorthand for responding to requests where the response does not require a body.