# config.Workspace.from_yaml

- **Module:** config.Workspace
- **Package:** tmux-workspace
- **Language:** Rust
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-rs/blob/f0e37052c232636b61d095817046e6bfc8f2ca40/crates/tmux-workspace/src/config.rs#L311
- **Page:** https://libtmux.org/en/rs/latest/workspace/reference/config-workspace-from_yaml/

```
config.Workspace.from_yaml(source: &str) -> Result<Self, ConfigError>
```

Parse one workspace from tmuxp-style YAML.

This accepts the shape tmuxp uses for the parts a builder needs. It is
deliberately not a full tmuxp implementation: unknown keys are ignored
rather than rejected, so a richer tmuxp file still loads.

As tmuxp does, it expands `~` and `$NAME` or `${NAME}` from this
process's environment in names, start directories, and `environment`
and option values, leaving an unset variable as written; commands are
typed as written, for the pane's shell to expand. A start directory
that begins with `.` is relative to the one it inherits, or to the
current directory at the top: [`Self::from_file`] uses the file's
directory instead.

# Errors

Returns an error when the document is not valid YAML, does not hold
exactly one workspace, or is missing `session_name`. Every error
except the document count names the line and column to look at.

## Example

```rust
use tmux_workspace::Workspace;

let workspace = Workspace::from_yaml(
    "
session_name: demo
windows:
  - window_name: editor
    panes:
      - echo one
      - shell_command: echo two
",
)?;

assert_eq!(workspace.session_name, "demo");
assert_eq!(workspace.windows.len(), 1);
assert_eq!(workspace.windows[0].panes.len(), 2);
```
