Skip to main content

DecorationCtx

Struct DecorationCtx 

Source
pub struct DecorationCtx<'a> {
    pub buffer_id: BufferId,
    /* private fields */
}
Expand description

Read-only context passed to crate::Mode::gutter_decorations.

Dependency inversion: the renderer builds a per-pane ServiceRegistry of typed render-state snapshots (diff sign map, LSP diagnostics, CompilationSeverityData, BuiltinSignIds, …) and each mode pulls only the data it knows about through service. The renderer therefore never depends on the crate that owns a mode, and a mode never sees another mode’s data.

Built once per pane per frame, on the render path: a gutter_decorations implementation must do nothing heavier than a map over data already computed off-thread.

§Examples

use lattice_core::BufferId;
use lattice_mode::{DecorationCtx, ServiceRegistry};

struct MyMarks(Vec<u32>);

let mut services = ServiceRegistry::new();
services.register(MyMarks(vec![3, 7]));
let ctx = DecorationCtx::new(BufferId(1), &services);

assert_eq!(ctx.service::<MyMarks>().unwrap().0, vec![3, 7]);
// A snapshot nobody injected is simply absent: contribute nothing.
assert!(ctx.service::<String>().is_none());

Fields§

§buffer_id: BufferId

The buffer shown in the pane being decorated.

Implementations§

Source§

impl<'a> DecorationCtx<'a>

Source

pub fn new(buffer_id: BufferId, services: &'a ServiceRegistry) -> Self

Build a context over services for the pane showing buffer_id. Called by the renderers, not by modes.

Source

pub fn service<T: Any + Send + Sync>(&self) -> Option<Arc<T>>

Typed lookup of a render-state snapshot the renderer injected. None when nothing of type T was registered for this frame — a stripped render path or data not yet produced — and the mode should then contribute nothing rather than fail. Same TypeId rule as ServiceRegistry::get: look up with exactly the registered type.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for DecorationCtx<'a>

§

impl<'a> !UnwindSafe for DecorationCtx<'a>

§

impl<'a> Freeze for DecorationCtx<'a>

§

impl<'a> Send for DecorationCtx<'a>

§

impl<'a> Sync for DecorationCtx<'a>

§

impl<'a> Unpin for DecorationCtx<'a>

§

impl<'a> UnsafeUnpin for DecorationCtx<'a>

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.

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