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: AtomicU32Implementations§
Source§impl ProcMacroServerProcess
impl ProcMacroServerProcess
Sourcepub(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>
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
Sourcepub(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>
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.
Sourcepub(crate) fn find_proc_macros(
&self,
dylib_path: &AbsPath,
) -> Result<Result<Vec<(String, ProcMacroKind)>, String>, ServerError>
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.
Sourcepub(crate) fn exited(&self) -> Option<&ServerError>
pub(crate) fn exited(&self) -> Option<&ServerError>
Returns the server error if the process has exited.
Sourcepub(crate) fn rust_analyzer_spans(&self) -> bool
pub(crate) fn rust_analyzer_spans(&self) -> bool
Enable support for rust-analyzer span mode if the server supports it.
Sourcefn version_check(
&self,
callback: Option<SubCallback<'_>>,
) -> Result<u32, ServerError>
fn version_check( &self, callback: Option<SubCallback<'_>>, ) -> Result<u32, ServerError>
Checks the API version of the running proc-macro server.
Sourcefn enable_rust_analyzer_spans(
&self,
callback: Option<SubCallback<'_>>,
) -> Result<SpanMode, ServerError>
fn enable_rust_analyzer_spans( &self, callback: Option<SubCallback<'_>>, ) -> Result<SpanMode, ServerError>
Enable support for rust-analyzer span mode if the server supports it.
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>
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>
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>
pub(crate) fn run_bidirectional( &self, initial: BidirectionalMessage, callback: SubCallback<'_>, ) -> Result<BidirectionalMessage, ServerError>
pub(crate) fn number_of_active_req(&self) -> u32
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ProcMacroServerProcess
impl RefUnwindSafe for ProcMacroServerProcess
impl Send for ProcMacroServerProcess
impl Sync for ProcMacroServerProcess
impl Unpin for ProcMacroServerProcess
impl UnwindSafe for ProcMacroServerProcess
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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