Skip to main content

WorkspaceBuilder

Struct WorkspaceBuilder 

Source
pub struct WorkspaceBuilder<'server> { /* private fields */ }
Expand description

Creates tmux sessions from workspace configurations.

Implementations§

Source§

impl<'server> WorkspaceBuilder<'server>

Source

pub const fn new(server: &'server Server) -> Self

Build workspaces on one server.

Source

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")));
Source

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§

Source§

impl<'server> Debug for WorkspaceBuilder<'server>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> 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.