ProcMacroServerProcess

Struct ProcMacroServerProcess 

Source
pub(crate) struct ProcMacroServerProcess {
    state: Mutex<ProcessSrvState>,
    version: u32,
    protocol: Protocol,
    exited: OnceLock<AssertUnwindSafe<ServerError>>,
    active: AtomicU32,
}
Expand description

Represents a process handling proc-macro communication.

Fields§

§state: Mutex<ProcessSrvState>

The state of the proc-macro server process, the protocol is currently strictly sequential hence the lock on the state.

§version: u32§protocol: Protocol§exited: OnceLock<AssertUnwindSafe<ServerError>>

Populated when the server exits.

§active: AtomicU32

Implementations§

Source§

impl ProcMacroServerProcess

Source

pub(crate) fn spawn<'a>( process_path: &AbsPath, env: impl IntoIterator<Item = (impl AsRef<OsStr>, &'a Option<impl 'a + AsRef<OsStr>>)> + Clone, version: Option<&Version>, ) -> Result<ProcMacroServerProcess>

Starts the proc-macro server and performs a version check

Source

pub(crate) fn run( spawn: impl Fn(Option<ProtocolFormat>) -> Result<(Box<dyn ProcessExit>, Box<dyn Write + Send + Sync>, Box<dyn BufRead + Send + Sync>)>, version: Option<&Version>, binary_server_version: impl Fn() -> String, ) -> Result<ProcMacroServerProcess>

Invokes spawn and performs a version check.

Source

pub(crate) fn find_proc_macros( &self, dylib_path: &AbsPath, ) -> Result<Result<Vec<(String, ProcMacroKind)>, String>, ServerError>

Finds proc-macros in a given dynamic library.

Source

pub(crate) fn exited(&self) -> Option<&ServerError>

Returns the server error if the process has exited.

Source

pub(crate) fn version(&self) -> u32

Retrieves the API version of the proc-macro server.

Source

pub(crate) fn rust_analyzer_spans(&self) -> bool

Enable support for rust-analyzer span mode if the server supports it.

Source

fn version_check( &self, callback: Option<SubCallback<'_>>, ) -> Result<u32, ServerError>

Checks the API version of the running proc-macro server.

Source

fn enable_rust_analyzer_spans( &self, callback: Option<SubCallback<'_>>, ) -> Result<SpanMode, ServerError>

Enable support for rust-analyzer span mode if the server supports it.

Source

pub(crate) fn expand( &self, proc_macro: &ProcMacro, subtree: SubtreeView<'_>, attr: Option<SubtreeView<'_>>, env: Vec<(String, String)>, def_site: Span, call_site: Span, mixed_site: Span, current_dir: String, callback: Option<SubCallback<'_>>, ) -> Result<Result<TopSubtree, String>, ServerError>

Source

pub(crate) fn send_task_legacy<Request, Response>( &self, send: impl FnOnce(&mut dyn Write, &mut dyn BufRead, Request, &mut String) -> Result<Option<Response>, ServerError>, req: Request, ) -> Result<Response, ServerError>

Source

fn with_locked_io<R, B>( &self, buf: B, f: impl FnOnce(&mut dyn Write, &mut dyn BufRead, &mut B) -> Result<R, ServerError>, ) -> Result<R, ServerError>

Source

pub(crate) fn run_bidirectional( &self, initial: BidirectionalMessage, callback: SubCallback<'_>, ) -> Result<BidirectionalMessage, ServerError>

Source

pub(crate) fn number_of_active_req(&self) -> u32

Trait Implementations§

Source§

impl Debug for ProcMacroServerProcess

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> IntoBox<dyn Any> for T
where T: Any,

§

fn into_box(self) -> Box<dyn Any>

Convert self into the appropriate boxed form.
§

impl<T> IntoBox<dyn Any + Send> for T
where T: Any + Send,

§

fn into_box(self) -> Box<dyn Any + Send>

Convert self into the appropriate boxed form.
§

impl<T> IntoBox<dyn Any + Send + Sync> for T
where T: Any + Send + Sync,

§

fn into_box(self) -> Box<dyn Any + Send + Sync>

Convert self into the appropriate boxed form.
Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more