pub struct SessionWorkspace {
pub root: PathBuf,
pub session_id: String,
pub is_sandbox: bool,
}Expand description
Session workspace configuration
Fields§
§root: PathBufThe root directory for this session’s workspace
session_id: StringSession ID this workspace belongs to
is_sandbox: boolWhether this is a user-provided directory or auto-generated sandbox
Implementations§
Source§impl SessionWorkspace
impl SessionWorkspace
Sourcepub fn create_sandbox(
session_id: &str,
) -> Result<SessionWorkspace, WorkspaceError>
pub fn create_sandbox( session_id: &str, ) -> Result<SessionWorkspace, WorkspaceError>
Create a new session workspace with an auto-generated sandbox directory
Creates a directory at ~/.gestura/sessions/<session_id>/
Sourcepub fn from_directory(
session_id: &str,
directory: PathBuf,
) -> Result<SessionWorkspace, WorkspaceError>
pub fn from_directory( session_id: &str, directory: PathBuf, ) -> Result<SessionWorkspace, WorkspaceError>
Create a session workspace using an existing directory
This is used when the user specifies a project directory (CLI cwd or GUI selection)
Sourcepub fn resolve_path(&self, path: &Path) -> Result<PathBuf, WorkspaceError>
pub fn resolve_path(&self, path: &Path) -> Result<PathBuf, WorkspaceError>
Resolve a path relative to the workspace root with full security validation
This method performs comprehensive security checks:
- Validates path for dangerous characters/patterns
- Checks path depth limits
- Validates symlinks point within workspace
- Ensures resolved path is within workspace bounds
Returns an error if any security check fails.
Sourcepub fn resolve_path_for_read(
&self,
path: &Path,
) -> Result<PathBuf, WorkspaceError>
pub fn resolve_path_for_read( &self, path: &Path, ) -> Result<PathBuf, WorkspaceError>
Resolve a path for reading (file must exist)
Additional validation for read operations including symlink target checks.
Sourcepub fn resolve_path_for_write(
&self,
path: &Path,
) -> Result<PathBuf, WorkspaceError>
pub fn resolve_path_for_write( &self, path: &Path, ) -> Result<PathBuf, WorkspaceError>
Resolve a path for writing (parent directory must exist)
Validates the parent directory exists and is writable.
Sourcepub fn resolve_path_for_create(
&self,
path: &Path,
) -> Result<PathBuf, WorkspaceError>
pub fn resolve_path_for_create( &self, path: &Path, ) -> Result<PathBuf, WorkspaceError>
Resolve a path for creation (file/dir may not exist yet).
This is similar to Self::resolve_path_for_write, but it does not require the
parent directory to exist. It is intended for tools that legitimately create output
directories as part of their operation (e.g. screen capture artifacts).
Security note: even when the target doesn’t exist yet, we still validate any existing path components for symlink escapes.
Sourcepub fn is_path_allowed(&self, path: &Path) -> bool
pub fn is_path_allowed(&self, path: &Path) -> bool
Check if a path is within the workspace (without resolving)
Sourcepub fn path_has_symlinks(&self, path: &Path) -> bool
pub fn path_has_symlinks(&self, path: &Path) -> bool
Check if a path contains any symlinks
Sourcepub fn get_metadata(&self, path: &Path) -> Result<Metadata, WorkspaceError>
pub fn get_metadata(&self, path: &Path) -> Result<Metadata, WorkspaceError>
Get file metadata with symlink awareness
Sourcepub fn get_symlink_metadata(
&self,
path: &Path,
) -> Result<Metadata, WorkspaceError>
pub fn get_symlink_metadata( &self, path: &Path, ) -> Result<Metadata, WorkspaceError>
Get symlink metadata (doesn’t follow symlinks)
Sourcepub fn cleanup(&self) -> Result<(), WorkspaceError>
pub fn cleanup(&self) -> Result<(), WorkspaceError>
Clean up the workspace directory (only for sandbox workspaces)
Trait Implementations§
Source§impl Clone for SessionWorkspace
impl Clone for SessionWorkspace
Source§fn clone(&self) -> SessionWorkspace
fn clone(&self) -> SessionWorkspace
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SessionWorkspace
impl RefUnwindSafe for SessionWorkspace
impl Send for SessionWorkspace
impl Sync for SessionWorkspace
impl Unpin for SessionWorkspace
impl UnwindSafe for SessionWorkspace
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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.§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.§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.§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.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§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>
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].