pub struct Previewer { /* private fields */ }Expand description
Non blocking preview builder.
Allow preview building without blocking status.
The process is quite complicated but fast.
We use 2 std::sync::mpsc :
- one to ask a preview to be built, sent from
crate::app::Statusitself, it’s received here in a separated thread and built outisde of status thread. - one to send the
crate::modes::Previewout of the thread to status. It’s the responsability of the application to force status to attach the preview.
ATM only the previews for the second pane are built here. It’s useless if the user display previews in the current tab since navigation isn’t possible.
Implementations§
Source§impl Previewer
impl Previewer
Sourcepub fn new(tx_preview: Sender<PreviewResponse>) -> Self
pub fn new(tx_preview: Sender<PreviewResponse>) -> Self
Starts the previewer loop in a thread and create a new instance with a std::sync::mpsc::Sender.
The previewer will wait for std::sync::mpsc::Receiver messages and react accordingly :
- if the message asks to quit, it will break the loop and leave.
- if the message is a request, it will create the associate preview and send it back to the application. The application should then ask the status to attach the preview. It’s complicated but I couldn’t find a simpler way to check for the preview.
Sourcepub fn quit(&self)
pub fn quit(&self)
Sends a “quit” message to the previewer loop. It will break the loop, exiting the previewer.
Sourcepub fn build(
&self,
path: PathBuf,
index: usize,
line_index: Option<usize>,
) -> Result<()>
pub fn build( &self, path: PathBuf, index: usize, line_index: Option<usize>, ) -> Result<()>
Sends an “ask preview” to the previewer loop. A preview will be built, which won’t block the application. Once the preview is built, it’s send back to status, which should be asked to attach the preview. The preview won’t be attached automatically, it’s the responsability of the application to do it.
Auto Trait Implementations§
impl Freeze for Previewer
impl RefUnwindSafe for Previewer
impl Send for Previewer
impl Sync for Previewer
impl Unpin for Previewer
impl UnwindSafe for Previewer
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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>
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