struct FmtFragServer {
data: Arc<Mutex<FmtFragServerData>>,
edition: String,
}Expand description
rustfmt does not provide a crate and does not implement a server. It only operates in one-shot calls and it is slow.
This service is a quick workaround that, it abuses the async state machine generation to inject a batching feature in the middle of the recursive custom fmt logic. It does not implement wakers, just keep polling to execute.
Fields§
§data: Arc<Mutex<FmtFragServerData>>§edition: StringImplementations§
Source§impl FmtFragServer
impl FmtFragServer
const PREFIX: &str = "fn __frag__() "
pub fn spawn(edition: String) -> Self
pub fn format(&self, code: String) -> impl Future<Output = Option<String>>
fn poll(&self)
fn wrap_batch_for_fmt<'a>(requests: impl Iterator<Item = &'a str>) -> String
fn unwrap_batch_for_fmt(fmt: String, count: usize) -> Vec<String>
Trait Implementations§
Source§impl Clone for FmtFragServer
impl Clone for FmtFragServer
Source§fn clone(&self) -> FmtFragServer
fn clone(&self) -> FmtFragServer
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for FmtFragServer
impl !RefUnwindSafe for FmtFragServer
impl Send for FmtFragServer
impl Sync for FmtFragServer
impl Unpin for FmtFragServer
impl !UnwindSafe for FmtFragServer
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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