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
impl Session
Sourcepub fn create_filter(&self) -> Result<HardwareFilter>
pub fn create_filter(&self) -> Result<HardwareFilter>
Create a new filter for the session to use as part of [find_hardware]
Sourcepub fn find_hardware(
&self,
filtering: Option<&HardwareFilter>,
experts: Option<&[ExpertType]>,
) -> Result<HardwareResourceList<'_>>
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 ofExpertTypeto 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
impl Session
Sourcepub 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<()>
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
imageshould be a path to the directory to be created with the image contents.image_infoprovides metadata to be saved with the image.encryption_passphraseshould be Some with a value if you wish to encrypt the image or None to save the image unencrypted.excluded_files_folderscan contain a list of files and folders which should not be captured in the image.auto_restartRestarts 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_existsdefines whether to replace an existing image in theimagepath.
Sourcepub 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<()>
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
imageshould be a path to the directory to be created with the image contents.encryption_passphraseshould be Some with a value if the image is encrypted or None if the image is unencrypted.excluded_files_folderscan contain a list of files and folders which should not be ovewritten on the tearget.auto_restartRestarts 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_onlydefines whether this should only be applied to the same system the image came from based on the MAC address.network_settingsdefines the state of the network configuration after the system image has been applied.