Skip to main content

WorkspaceFile

Struct WorkspaceFile 

Source
pub struct WorkspaceFile { /* private fields */ }
Expand description

Safe wrapper for TestStand™ WorkspaceFile (IWorkspaceFile).

Implementations§

Source§

impl WorkspaceFile

Source

pub fn as_property_object_file(&self) -> Result<PropertyObjectFile, Error>

The workspace seen as a property-object file (AsPropertyObjectFile).

A workspace is a file like any other underneath, so this is the route to its stored data and its registered types.

§Errors

Error if the COM call fails or returns an unexpected type.

Source

pub fn root_workspace_object(&self) -> Result<WorkspaceObject, Error>

Accesses the root workspace object (WorkspaceFile.RootWorkspaceObject).

§Errors

Error if the COM call fails or returns an unexpected type.

Examples found in repository?
examples/workspace_create.rs (line 10)
5fn main() -> Result<(), rs_teststand::Error> {
6    let engine = Engine::new()?;
7
8    println!("Creating a new workspace file...");
9    let ws_file = engine.new_workspace_file()?;
10    let root_obj = ws_file.root_workspace_object()?;
11
12    println!("Root workspace object:");
13    println!("  Display Name: '{}'", root_obj.display_name()?);
14    println!("  Object Type: {}", root_obj.object_type()?);
15    println!("  Child Objects: {}", root_obj.num_contained_objects()?);
16
17    println!("\nCreating project and folder structure...");
18    let project = root_obj.new_folder("Project Alpha")?;
19    println!("  Created project folder: '{}'", project.display_name()?);
20
21    let seq_entry = project.new_file("MainTest.seq")?;
22    println!(
23        "  Created sequence file entry: '{}'",
24        seq_entry.display_name()?
25    );
26
27    println!(
28        "\nUpdated root child objects count: {}",
29        root_obj.num_contained_objects()?
30    );
31
32    Ok(())
33}
Source

pub fn provider_name(&self) -> Result<Option<String>, Error>

The source code control provider this workspace names (WorkspaceFile.ProviderName).

Three states, all distinct:

  • None, the workspace names no provider.
  • Some(""), defer to the system default provider.
  • Some(name), that named provider.
§Errors

Error if the COM call fails or returns an unexpected type.

Source

pub fn set_provider_name(&self, name: &str) -> Result<(), Error>

Names the source code control provider (WorkspaceFile.ProviderName).

Pass an empty string to defer to the system default provider.

§Errors

Error if the COM call fails.

Source

pub fn is_connected_to_sc_provider(&self) -> Result<bool, Error>

Whether this workspace is connected to a source code control provider (WorkspaceFile.IsConnectedToSCProvider).

Connection is a side effect of the engine adopting the workspace, not something this type performs, so a freshly opened file can report false until the engine takes it as the current workspace.

§Errors

Error if the COM call fails or returns an unexpected type.

Source

pub fn save_workspace_and_project_files( &self, options: i32, ) -> Result<bool, Error>

Writes the workspace and its projects to disk if they have been modified (WorkspaceFile.SaveWorkspaceAndProjectFiles).

This method can raise a dialog and is therefore unsafe on an unattended host. When there are modifications it asks the user before writing, and a false return means precisely that they declined, not that the save failed. Nothing is prompted or written when nothing has changed. A failure to write is reported as an error naming the files, not as false.

Engine-level dialog suppression does not cover this one; it is a deliberate confirmation, not a configurable prompt. Guard the call with a Watchdog if a service must make it at all.

§Errors

Error if the COM call fails or any file cannot be written.

Source

pub fn find_workspace_object( &self, path: &str, ) -> Result<Option<WorkspaceObject>, Error>

Finds a workspace object by lookup path (WorkspaceFile.FindWorkspaceObject).

§Errors

Error if the COM call fails or returns an unexpected type.

Trait Implementations§

Source§

impl Debug for WorkspaceFile

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.