Session

Struct Session 

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

Provides an interface to an active system configuration session.

This is created when you connect to a target using SessionConfig and allows you to access hardware and software resources through the API.

Implementations§

Source§

impl Session

Source

pub fn create_filter(&self) -> Result<HardwareFilter>

Create a new filter for the session to use as part of [find_hardware]

Source

pub fn find_hardware( &self, filtering: Option<&HardwareFilter>, experts: Option<&[ExpertType]>, ) -> Result<HardwareResourceList<'_>>

Find the hardware resources in the system, optionally with the filter settings.

  • [filtering] can provide a hardware filter or None for no filtering.
  • [experts] can be a slice of ExpertType to limit results to specific types or None for all supported experts.
§Example Without Filtering
use ni_syscfg::SessionConfig;

let session = SessionConfig::new().connect().unwrap();

for hardware in session.find_hardware(None, None).unwrap() {
  println!("Found {}", hardware.name().unwrap())
}
§Example With Filtering
use ni_syscfg::{SessionConfig, FilterMode};

let session = SessionConfig::new().connect().unwrap();
let mut filter = session.create_filter().unwrap();
filter.set_mode(FilterMode::MatchValuesAny);

for hardware in session.find_hardware(Some(&filter), None).unwrap() {
  println!("Found {}", hardware.name().unwrap())
}
§Example With DAQmx Expert Filter
use ni_syscfg::{SessionConfig, ExpertType};

let session = SessionConfig::new().connect().unwrap();

for hardware in session.find_hardware(None, Some(&[ExpertType::NiDaqmx])).unwrap() {
  println!("Found {}", hardware.name().unwrap())
}
Source§

impl Session

Source

pub fn get_system_image( &self, image: &Path, image_info: &ImageInfo, encryption_passphrase: Option<&str>, excluded_files_folders: &[&str], auto_restart: bool, overwrite_if_exists: bool, ) -> Result<()>

Creates an image of the system in the image path. The image is a folder containing metadata and the disk image.

This wraps the NISysCfgCreateSystemImageAsFolder method from the C API.

§Parameters
  • image should be a path to the directory to be created with the image contents.
  • image_info provides metadata to be saved with the image.
  • encryption_passphrase should be Some with a value if you wish to encrypt the image or None to save the image unencrypted.
  • excluded_files_folders can contain a list of files and folders which should not be captured in the image.
  • auto_restart Restarts the system into install mode by default before the operation is performed, and restarts back to a running state after the operation is complete. If you choose not to restart automatically, and the system is not in install mode, this function returns an error.
  • overwrite_if_exists defines whether to replace an existing image in the image path.
Source

pub fn set_system_image( &self, image: &Path, encryption_passphrase: Option<&str>, excluded_files_folders: &[&str], auto_restart: bool, original_system_only: bool, network_settings: NetworkInterfaceSettings, ) -> Result<()>

Copy a system image to the target from the image path. The image is a folder containing metadata and the disk image captured with Session::get_system_image

This wraps the NISysCfgSetSystemImageFromFolder2 method from the C API.

§Parameters
  • image should be a path to the directory to be created with the image contents.
  • encryption_passphrase should be Some with a value if the image is encrypted or None if the image is unencrypted.
  • excluded_files_folders can contain a list of files and folders which should not be ovewritten on the tearget.
  • auto_restart Restarts the system into install mode by default before the operation is performed, and restarts back to a running state after the operation is complete. If you choose not to restart automatically, and the system is not in install mode, the resulting image may not be valid.
  • original_system_only defines whether this should only be applied to the same system the image came from based on the MAC address.
  • network_settings defines the state of the network configuration after the system image has been applied.

Trait Implementations§

Source§

impl Drop for Session

Source§

fn drop(&mut self)

Executes the destructor for this type. 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.