pub struct WorkspaceBuilder<'server> { /* private fields */ }Expand description
Creates tmux sessions from workspace configurations.
Implementations§
Source§impl<'server> WorkspaceBuilder<'server>
impl<'server> WorkspaceBuilder<'server>
Sourcepub fn plan(&self, workspace: &Workspace) -> Plan
pub fn plan(&self, workspace: &Workspace) -> Plan
Describe what building this workspace would do, without doing it.
The returned plan is inert, so a caller can render it, count what it costs, or explain it before anything reaches tmux. Every object a later step addresses is a forward reference to the step that makes it, so the whole file lowers without a single round trip to look an id up.
§Examples
use tmux_workspace::{Workspace, WorkspaceBuilder};
let workspace = Workspace::from_yaml(
"
session_name: dev
windows:
- window_name: editor
panes:
- vim
",
)?;
let server = libtmux::Server::builder()
.socket_path("/tmp/libtmux-rs-test/plan-example.sock")
.build()?;
let plan = WorkspaceBuilder::new(&server).plan(&workspace);
// Nothing has run, but the first command is already known.
assert!(plan.preview()[0]
.as_ref()
.is_some_and(|command| command.summary().to_string().contains("new-session")));Sourcepub async fn build(&self, workspace: &Workspace) -> Result<Session, BuildError>
pub async fn build(&self, workspace: &Workspace) -> Result<Session, BuildError>
Create the session a workspace describes, and return it.
Windows and panes are created in the order the configuration lists them. Nothing is attached: the caller decides whether to take over a terminal.
§Errors
Returns an error when a session of the same name exists, or when tmux refuses any step.
Trait Implementations§
Auto Trait Implementations§
impl<'server> !RefUnwindSafe for WorkspaceBuilder<'server>
impl<'server> !UnwindSafe for WorkspaceBuilder<'server>
impl<'server> Freeze for WorkspaceBuilder<'server>
impl<'server> Send for WorkspaceBuilder<'server>
impl<'server> Sync for WorkspaceBuilder<'server>
impl<'server> Unpin for WorkspaceBuilder<'server>
impl<'server> UnsafeUnpin for WorkspaceBuilder<'server>
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
Mutably borrows from an owned value. Read more