# config.Workspace.from_file

- **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#L341
- **Page:** https://libtmux.org/en/rs/latest/workspace/reference/config-workspace-from_file/

```
config.Workspace.from_file(path: impl AsRef<Path>) -> Result<Self, ConfigError>
```

Read and parse one workspace file, as `tmuxp load` does.

Everything [`Self::from_yaml`] says holds, except that a start
directory beginning with `.` and inheriting none is relative to the
file's directory. JSON is read too, as the YAML it is a subset of.

# Errors

Returns [`ConfigError::Read`] when the file cannot be read, and
otherwise what [`Self::from_yaml`] returns.

## Example

```rust
use tmux_workspace::Workspace;

let project = tempfile::tempdir()?;
let file = project.path().join(".tmuxp.yaml");
std::fs::write(&file, "session_name: project\nstart_directory: ./\n")?;

let workspace = Workspace::from_file(&file)?;
assert_eq!(workspace.start_directory.as_deref(), Some(project.path()));
```
