Skip to content

editor

Structs

  • Editor - Editor command used to open a policy source file.
  • EditorExit - Result reported by an editor process after it started.
  • EditorLaunch - Inert process launch used to open a policy source file.

Traits

  • EditorProcess - Side-effect boundary used to run an editor launch.

Struct

Editor command used to open a policy source file.

The command is usually read from EDITOR. When it is not configured, the platform launch uses the local fallback editor.

Methods:

  • fn new(command: Option<OsString>) -> Self - Creates an editor from an optional command.
  • fn launch_for(self: &Self, path: &Path) -> EditorLaunch - Builds the platform-specific process launch used to open path.
  • fn open_with<impl EditorProcess>(self: &Self, path: &Path, process: & mut impl Trait) -> Result<(), EditorError> - Opens path and waits for the editor to exit.

Traits: Eq

Trait Implementations:

  • PartialEq
    • fn eq(self: &Self, other: &Editor) -> bool
  • Default
    • fn default() -> Editor
  • Clone
    • fn clone(self: &Self) -> Editor
  • Debug
    • fn fmt(self: &Self, f: & mut $crate::fmt::Formatter) -> $crate::fmt::Result

Struct

Result reported by an editor process after it started.

Start failures are represented by [EditorProcessError]. This type only describes a process that was launched and then exited.

Methods:

  • fn successful() -> Self - Creates a successful editor exit.
  • fn unsuccessful<impl Into<String>>(status: impl Trait) -> Self - Creates an unsuccessful editor exit with the rendered process status.

Traits: Eq

Trait Implementations:

  • Clone
    • fn clone(self: &Self) -> EditorExit
  • PartialEq
    • fn eq(self: &Self, other: &EditorExit) -> bool
  • Debug
    • fn fmt(self: &Self, f: & mut $crate::fmt::Formatter) -> $crate::fmt::Result

Struct

Inert process launch used to open a policy source file.

This value is kept separate from [Command] so the launch contract can be inspected before any side effect happens. Only [EditorProcess] turns it into a running process.

Methods:

  • fn new<impl Into<OsString>>(program: impl Trait) -> Self - Creates an editor launch for program.
  • fn args<I, A>(self: Self, args: I) -> Self - Adds arguments to this launch.
  • fn env<impl Into<OsString>, impl Into<OsString>>(self: Self, key: impl Trait, value: impl Trait) -> Self - Sets an environment variable for this launch.
  • fn remove_env<impl Into<OsString>>(self: Self, key: impl Trait) -> Self - Removes an environment variable for this launch.
  • fn program(self: &Self) -> &OsStr - Returns the program that will be passed to [Command].
  • fn arguments(self: &Self) -> &[OsString] - Returns the arguments that will be passed to [Command].
  • fn envs(self: &Self) -> &[(OsString, Option<OsString>)] - Returns the environment changes that will be applied to [Command].
  • fn into_command(self: Self) -> Command - Converts this launch into a process command without starting it.

Traits: Eq

Trait Implementations:

  • PartialEq
    • fn eq(self: &Self, other: &EditorLaunch) -> bool
  • Debug
    • fn fmt(self: &Self, f: & mut $crate::fmt::Formatter) -> $crate::fmt::Result
  • Clone
    • fn clone(self: &Self) -> EditorLaunch

Trait

Side-effect boundary used to run an editor launch.

Keeping process execution behind this boundary lets tests observe editor behavior without spawning a real editor, while production still uses the same launch value.

Methods:

  • run: Starts the editor process and waits for it to exit.