Skip to main content

RequestQueue

Struct RequestQueue 

Source
pub struct RequestQueue<I, O> {
    pub incoming: IncomingRequests<I>,
    pub outgoing: OutgoingRequests<O>,
}
Expand description

Combined request queue tracking both incoming and outgoing requests.

This is the primary type for managing LSP request-response correlation. It provides separate tracking for:

  • incoming: Requests received from clients that need responses
  • outgoing: Requests sent to clients that are awaiting responses

§Type Parameters

  • I: Metadata type for incoming requests (e.g., handler context)
  • O: Response type for outgoing requests

§Example

use lsp_server_tokio::{RequestQueue, RequestId};
use tokio_util::sync::CancellationToken;

// Create a queue for a server that tracks method names for incoming
// requests and expects JSON responses for outgoing requests
let mut queue: RequestQueue<String, serde_json::Value> = RequestQueue::new();

// Track incoming request with cancellation token
let token = CancellationToken::new();
queue.incoming.register(1.into(), "textDocument/hover".to_string(), token);

// Operations on incoming don't affect outgoing
assert_eq!(queue.incoming.pending_count(), 1);
assert_eq!(queue.outgoing.pending_count(), 0);

Fields§

§incoming: IncomingRequests<I>

Tracker for requests received from clients.

§outgoing: OutgoingRequests<O>

Tracker for requests sent to clients.

Implementations§

Source§

impl<I, O> RequestQueue<I, O>

Source

pub fn new() -> Self

Creates a new empty request queue.

Trait Implementations§

Source§

impl<I: Debug, O: Debug> Debug for RequestQueue<I, O>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<I, O> Default for RequestQueue<I, O>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<I, O> Freeze for RequestQueue<I, O>

§

impl<I, O> !RefUnwindSafe for RequestQueue<I, O>

§

impl<I, O> Send for RequestQueue<I, O>
where I: Send, O: Send,

§

impl<I, O> Sync for RequestQueue<I, O>
where I: Sync, O: Send,

§

impl<I, O> Unpin for RequestQueue<I, O>
where I: Unpin,

§

impl<I, O> UnsafeUnpin for RequestQueue<I, O>

§

impl<I, O> !UnwindSafe for RequestQueue<I, O>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.