pub trait BufferScopeSource:
Send
+ Sync
+ Debug {
// Required method
fn scope_dir_for_name(&self, buffer_name: &str) -> Option<PathBuf>;
}Expand description
A provider’s answer to “which directory is the buffer called this about?”, asked by the host the moment it creates a synthetic buffer.
§Why by name, and why a pull rather than a push
A provider that opens its buffer with Effect::OpenSyntheticBuffer never
touches the buffer: it returns a name and a mode id, and the host does the
rest. So it has no BufferId to attach a
BufferScopeDir to, and by the time its mode’s
on_activate runs there is no &mut reach into the buffer-local map
either.
It does, however, know the directory before the buffer exists — that is
the whole reason magit’s RepoScopes is keyed by name rather than by id.
So the host asks, at creation, with the one thing both sides have: the
name.
The alternative was a scope_dir field on Effect::OpenSyntheticBuffer,
which is ABI churn on a widely-constructed effect (and on its WIT peer) to
carry data most callers do not have.
Required Methods§
Sourcefn scope_dir_for_name(&self, buffer_name: &str) -> Option<PathBuf>
fn scope_dir_for_name(&self, buffer_name: &str) -> Option<PathBuf>
The directory a buffer named buffer_name is about, if this source
knows. None for a name it does not recognise — every source is asked
and most will not know.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".