Skip to main content

PathBroker

Struct PathBroker 

Source
pub struct PathBroker { /* private fields */ }

Implementations§

Source§

impl PathBroker

Source

pub fn new() -> Self

Source

pub fn with_app_name(app_name: &str) -> Self

A broker whose denial text names the app (“open it through {app_name} first”), taken from the shell’s app_name config. An empty name reads as “the app”.

Source

pub fn grant_file(&self, path: impl AsRef<Path>) -> Result<String, ShellError>

Grant an existing file the user chose. Returns the display path.

Source

pub fn grant_save_target( &self, path: impl AsRef<Path>, ) -> Result<String, ShellError>

Grant a path the user picked in a save dialog (it need not exist).

Source

pub fn grant_normalized(&self, path: PathBuf) -> Result<String, ShellError>

Source

pub fn is_granted_normalized(&self, path: &Path) -> Result<bool, ShellError>

Source

pub fn require_file(&self, path: &str) -> Result<String, ShellError>

Canonicalise path and require it to be a granted existing file.

Source

pub fn require_write_target(&self, path: &str) -> Result<String, ShellError>

Source

pub fn record_write_target(&self, path: &Path) -> Result<(), ShellError>

Record a path the app just wrote; evicts the oldest past WRITE_TARGET_RING_CAP.

Source

pub fn was_recently_written(&self, path: &Path) -> Result<bool, ShellError>

Source

pub fn regrant_saved_target(&self, path: &str) -> Result<String, ShellError>

Re-grant a save-as target that was just written (so the renderer cannot ask for any existing path to be granted).

Source

pub fn register_known_path(&self, path: &str) -> Result<String, ShellError>

Mint a one-shot recent-file id for a stored path (re-canonicalised: older rows or platform spelling differences must not grant something later checks reject).

Source

pub fn grant_known(&self, id: &str) -> Result<String, ShellError>

Trade a recent-file id for a grant. One shot: replaying it fails.

Source

pub fn revoke_path(&self, display: &str) -> Result<(), ShellError>

Revoke a grant (its last tab closed) and every stream id for that file, so old stream URLs die now and never revive on reopen. Matches by display string, so a file deleted after opening is still revoked.

Source

pub fn grant_stream(&self, path: &str) -> Result<String, ShellError>

Opaque URL id for a granted file. One stable live id per file: re-reading after an atomic edit overlaps in-flight range requests, and rotating would 403 the URL still loading.

Source

pub fn resolve_stream(&self, id: &str) -> Result<StreamTarget, ShellError>

Source

pub fn grant_site_root( &self, dir: impl AsRef<Path>, ) -> Result<String, ShellError>

Opaque id for a directory the preview may read subresources from. Authorises only containment-checked reads through PathBroker::resolve_in_site_root, never general document access. One id per grant (not deduplicated by directory) so two tabs on the same project do not revoke each other.

Source

pub fn resolve_site_root(&self, id: &str) -> Result<PathBuf, ShellError>

Source

pub fn resolve_in_site_root( &self, id: &str, relative: &str, ) -> Result<PathBuf, ShellError>

Resolve relative under a site root; refuses anything that escapes it (.., symlinks).

Source

pub fn revoke_site_root(&self, id: &str) -> Result<(), ShellError>

Trait Implementations§

Source§

impl Default for PathBroker

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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.

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.