use crate::error::{IronError, Result};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::time::Instant;
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ServiceStatus {
Running,
Stopped,
Starting,
Stopping,
Failed,
Unknown,
NotFound,
Exited,
}
impl std::fmt::Display for ServiceStatus {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ServiceStatus::Running => write!(f, "running"),
ServiceStatus::Stopped => write!(f, "stopped"),
ServiceStatus::Starting => write!(f, "starting"),
ServiceStatus::Stopping => write!(f, "stopping"),
ServiceStatus::Failed => write!(f, "failed"),
ServiceStatus::Unknown => write!(f, "unknown"),
ServiceStatus::NotFound => write!(f, "not-found"),
ServiceStatus::Exited => write!(f, "exited"),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ServiceType {
Simple,
Forking,
Oneshot,
Dbus,
Notify,
Idle,
Win32,
Unknown,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum StartupType {
Automatic,
Manual,
Disabled,
OnDemand,
Unknown,
}
impl std::fmt::Display for StartupType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
StartupType::Automatic => write!(f, "automatic"),
StartupType::Manual => write!(f, "manual"),
StartupType::Disabled => write!(f, "disabled"),
StartupType::OnDemand => write!(f, "on-demand"),
StartupType::Unknown => write!(f, "unknown"),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ServiceInfo {
pub name: String,
pub display_name: Option<String>,
pub status: ServiceStatus,
pub service_type: ServiceType,
pub startup_type: StartupType,
pub pid: Option<u32>,
pub memory_bytes: Option<u64>,
pub cpu_time_secs: Option<f64>,
pub exit_code: Option<i32>,
pub unit_file: Option<String>,
pub dependencies: Vec<String>,
pub dependents: Vec<String>,
pub enabled: Option<bool>,
pub load_state: Option<String>,
pub sub_state: Option<String>,
pub error_message: Option<String>,
pub start_time: Option<String>,
}
impl ServiceInfo {
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
display_name: None,
status: ServiceStatus::Unknown,
service_type: ServiceType::Unknown,
startup_type: StartupType::Unknown,
pid: None,
memory_bytes: None,
cpu_time_secs: None,
exit_code: None,
unit_file: None,
dependencies: Vec::new(),
dependents: Vec::new(),
enabled: None,
load_state: None,
sub_state: None,
error_message: None,
start_time: None,
}
}
pub fn is_active(&self) -> bool {
self.status == ServiceStatus::Running
}
pub fn is_failed(&self) -> bool {
self.status == ServiceStatus::Failed
}
}
pub struct ServiceMonitor {
services: Vec<ServiceInfo>,
service_map: HashMap<String, usize>,
last_update: Instant,
filter: Option<Vec<String>>,
}
impl ServiceMonitor {
pub fn new() -> Result<Self> {
let mut monitor = Self {
services: Vec::new(),
service_map: HashMap::new(),
last_update: Instant::now(),
filter: None,
};
monitor.discover()?;
Ok(monitor)
}
pub fn with_filter(service_names: Vec<String>) -> Result<Self> {
let service_names = service_names
.into_iter()
.map(|n| normalise_service_name(&n).to_string())
.collect();
let mut monitor = Self {
services: Vec::new(),
service_map: HashMap::new(),
last_update: Instant::now(),
filter: Some(service_names),
};
monitor.discover()?;
Ok(monitor)
}
pub fn refresh(&mut self) -> Result<()> {
self.services.clear();
self.service_map.clear();
self.discover()?;
self.last_update = Instant::now();
Ok(())
}
pub fn services(&self) -> &[ServiceInfo] {
&self.services
}
pub fn get_service(&self, name: &str) -> Option<&ServiceInfo> {
self.service_map
.get(normalise_service_name(name))
.and_then(|&idx| self.services.get(idx))
}
pub fn running_services(&self) -> Vec<&ServiceInfo> {
self.services
.iter()
.filter(|s| s.status == ServiceStatus::Running)
.collect()
}
pub fn failed_services(&self) -> Vec<&ServiceInfo> {
self.services
.iter()
.filter(|s| s.status == ServiceStatus::Failed)
.collect()
}
pub fn is_active(&self, name: &str) -> Option<bool> {
self.get_service(name).map(|s| s.is_active())
}
pub fn start(&self, name: &str) -> Result<()> {
#[cfg(target_os = "linux")]
{
self.linux_start_service(name)
}
#[cfg(target_os = "windows")]
{
self.windows_start_service(name)
}
#[cfg(not(any(target_os = "linux", target_os = "windows")))]
{
let _ = name;
Err(IronError::UnsupportedPlatform(
"Service control not supported".to_string(),
))
}
}
pub fn stop(&self, name: &str) -> Result<()> {
#[cfg(target_os = "linux")]
{
self.linux_stop_service(name)
}
#[cfg(target_os = "windows")]
{
self.windows_stop_service(name)
}
#[cfg(not(any(target_os = "linux", target_os = "windows")))]
{
let _ = name;
Err(IronError::UnsupportedPlatform(
"Service control not supported".to_string(),
))
}
}
pub fn restart(&self, name: &str) -> Result<()> {
#[cfg(target_os = "linux")]
{
self.linux_restart_service(name)
}
#[cfg(target_os = "windows")]
{
self.windows_stop_service(name)?;
std::thread::sleep(std::time::Duration::from_millis(500));
self.windows_start_service(name)
}
#[cfg(not(any(target_os = "linux", target_os = "windows")))]
{
let _ = name;
Err(IronError::UnsupportedPlatform(
"Service control not supported".to_string(),
))
}
}
pub fn enable(&self, name: &str) -> Result<()> {
#[cfg(target_os = "linux")]
{
self.linux_enable_service(name)
}
#[cfg(target_os = "windows")]
{
self.windows_set_startup(name, StartupType::Automatic)
}
#[cfg(not(any(target_os = "linux", target_os = "windows")))]
{
let _ = name;
Err(IronError::UnsupportedPlatform(
"Service control not supported".to_string(),
))
}
}
pub fn disable(&self, name: &str) -> Result<()> {
#[cfg(target_os = "linux")]
{
self.linux_disable_service(name)
}
#[cfg(target_os = "windows")]
{
self.windows_set_startup(name, StartupType::Manual)
}
#[cfg(not(any(target_os = "linux", target_os = "windows")))]
{
let _ = name;
Err(IronError::UnsupportedPlatform(
"Service control not supported".to_string(),
))
}
}
fn discover(&mut self) -> Result<()> {
#[cfg(target_os = "linux")]
{
self.linux_discover()
}
#[cfg(target_os = "windows")]
{
self.windows_discover()
}
#[cfg(target_os = "macos")]
{
self.macos_discover()
}
#[cfg(not(any(target_os = "linux", target_os = "windows", target_os = "macos")))]
{
Ok(())
}
}
#[cfg(target_os = "linux")]
fn linux_discover(&mut self) -> Result<()> {
use std::process::Command;
let output = Command::new("systemctl")
.args([
"list-units",
"--type=service",
"--all",
"--no-pager",
"--no-legend",
])
.output();
let output = output.map_err(|e| IronError::HardwareError(format!("systemctl: {e}")))?;
if !output.status.success() {
return Err(IronError::HardwareError(
"systemctl list-units --type=service failed".to_string(),
));
}
if let Ok(stdout) = String::from_utf8(output.stdout) {
for line in stdout.lines() {
if let Some(service) = self.linux_parse_service_line(line) {
if let Some(ref filter) = self.filter {
if !filter.iter().any(|f| service.name.contains(f)) {
continue;
}
}
let idx = self.services.len();
self.service_map.insert(service.name.clone(), idx);
self.services.push(service);
}
}
}
let mut services = std::mem::take(&mut self.services);
for service in &mut services {
self.linux_get_service_details(service);
}
self.services = services;
Ok(())
}
#[cfg(target_os = "linux")]
fn linux_parse_service_line(&self, line: &str) -> Option<ServiceInfo> {
let parts: Vec<&str> = line.split_whitespace().collect();
if parts.len() < 4 {
return None;
}
let name = parts[0].trim_end_matches(".service").to_string();
let load_state = parts[1].to_string();
let active_state = parts[2].to_string();
let sub_state = parts[3].to_string();
let status = match active_state.as_str() {
"active" => match sub_state.as_str() {
"running" => ServiceStatus::Running,
"exited" => ServiceStatus::Exited,
"waiting" => ServiceStatus::Starting,
_ => ServiceStatus::Unknown,
},
"inactive" => ServiceStatus::Stopped,
"failed" => ServiceStatus::Failed,
"activating" => ServiceStatus::Starting,
"deactivating" => ServiceStatus::Stopping,
_ => ServiceStatus::Unknown,
};
let mut service = ServiceInfo::new(&name);
service.status = status;
service.load_state = Some(load_state);
service.sub_state = Some(sub_state);
if parts.len() > 4 {
service.display_name = Some(parts[4..].join(" "));
}
Some(service)
}
#[cfg(target_os = "linux")]
fn linux_get_service_details(&self, service: &mut ServiceInfo) {
use std::process::Command;
let output = Command::new("systemctl")
.args(["show", &format!("{}.service", service.name)])
.output();
if let Ok(output) = output {
if let Ok(stdout) = String::from_utf8(output.stdout) {
for line in stdout.lines() {
if let Some((key, value)) = line.split_once('=') {
match key {
"MainPID" => {
if let Ok(pid) = value.parse::<u32>() {
if pid > 0 {
service.pid = Some(pid);
}
}
}
"MemoryCurrent" => {
if let Ok(mem) = value.parse::<u64>() {
if mem < u64::MAX {
service.memory_bytes = Some(mem);
}
}
}
"ActiveEnterTimestamp" => {
if !value.is_empty() {
service.start_time = Some(value.to_string());
}
}
"Type" => {
service.service_type = match value {
"simple" => ServiceType::Simple,
"forking" => ServiceType::Forking,
"oneshot" => ServiceType::Oneshot,
"dbus" => ServiceType::Dbus,
"notify" => ServiceType::Notify,
"idle" => ServiceType::Idle,
_ => ServiceType::Unknown,
};
}
"UnitFileState" => {
if !value.is_empty() {
service.enabled = Some(value == "enabled");
}
service.startup_type = match value {
"enabled" => StartupType::Automatic,
"disabled" => StartupType::Disabled,
"static" => StartupType::Manual,
"masked" => StartupType::Disabled,
_ => StartupType::Unknown,
};
}
"FragmentPath" => {
if !value.is_empty() {
service.unit_file = Some(value.to_string());
}
}
"Requires" | "Wants" => {
for dep in value.split_whitespace() {
let dep_name = dep.trim_end_matches(".service");
if !dep_name.is_empty() {
service.dependencies.push(dep_name.to_string());
}
}
}
"RequiredBy" | "WantedBy" => {
for dep in value.split_whitespace() {
let dep_name = dep.trim_end_matches(".service");
if !dep_name.is_empty() {
service.dependents.push(dep_name.to_string());
}
}
}
_ => {}
}
}
}
}
}
}
#[cfg(target_os = "linux")]
fn linux_start_service(&self, name: &str) -> Result<()> {
use std::process::Command;
let status = Command::new("systemctl")
.args(["start", &format!("{}.service", name)])
.status();
match status {
Ok(s) if s.success() => Ok(()),
Ok(_) => Err(IronError::System(format!(
"Failed to start service '{}' (check permissions)",
name
))),
Err(e) => Err(IronError::System(format!(
"Failed to execute systemctl: {}",
e
))),
}
}
#[cfg(target_os = "linux")]
fn linux_stop_service(&self, name: &str) -> Result<()> {
use std::process::Command;
let status = Command::new("systemctl")
.args(["stop", &format!("{}.service", name)])
.status();
match status {
Ok(s) if s.success() => Ok(()),
Ok(_) => Err(IronError::System(format!(
"Failed to stop service '{}' (check permissions)",
name
))),
Err(e) => Err(IronError::System(format!(
"Failed to execute systemctl: {}",
e
))),
}
}
#[cfg(target_os = "linux")]
fn linux_restart_service(&self, name: &str) -> Result<()> {
use std::process::Command;
let status = Command::new("systemctl")
.args(["restart", &format!("{}.service", name)])
.status();
match status {
Ok(s) if s.success() => Ok(()),
Ok(_) => Err(IronError::System(format!(
"Failed to restart service '{}' (check permissions)",
name
))),
Err(e) => Err(IronError::System(format!(
"Failed to execute systemctl: {}",
e
))),
}
}
#[cfg(target_os = "linux")]
fn linux_enable_service(&self, name: &str) -> Result<()> {
use std::process::Command;
let status = Command::new("systemctl")
.args(["enable", &format!("{}.service", name)])
.status();
match status {
Ok(s) if s.success() => Ok(()),
Ok(_) => Err(IronError::System(format!(
"Failed to enable service '{}' (check permissions)",
name
))),
Err(e) => Err(IronError::System(format!(
"Failed to execute systemctl: {}",
e
))),
}
}
#[cfg(target_os = "linux")]
fn linux_disable_service(&self, name: &str) -> Result<()> {
use std::process::Command;
let status = Command::new("systemctl")
.args(["disable", &format!("{}.service", name)])
.status();
match status {
Ok(s) if s.success() => Ok(()),
Ok(_) => Err(IronError::System(format!(
"Failed to disable service '{}' (check permissions)",
name
))),
Err(e) => Err(IronError::System(format!(
"Failed to execute systemctl: {}",
e
))),
}
}
#[cfg(target_os = "windows")]
fn windows_discover(&mut self) -> Result<()> {
use std::process::Command;
let output = Command::new("powershell")
.args([
"-NoProfile",
"-Command",
"Get-Service | Select-Object Name, DisplayName, Status, StartType | ConvertTo-Json",
])
.output()
.map_err(|e| IronError::HardwareError(format!("powershell: {e}")))?;
if !output.status.success() {
return Err(IronError::HardwareError("Get-Service failed".to_string()));
}
let stdout = String::from_utf8(output.stdout)
.map_err(|e| IronError::HardwareError(format!("Get-Service output: {e}")))?;
self.windows_parse_services(&stdout)
}
#[cfg(target_os = "windows")]
fn windows_parse_services(&mut self, json_str: &str) -> Result<()> {
#[derive(serde::Deserialize)]
struct PsService {
#[serde(rename = "Name")]
name: Option<String>,
#[serde(rename = "DisplayName")]
display_name: Option<String>,
#[serde(rename = "Status")]
status: Option<i32>,
#[serde(rename = "StartType")]
start_type: Option<i32>,
}
let services: Vec<PsService> = serde_json::from_str(json_str).map_err(|e| {
IronError::HardwareError(format!("Get-Service JSON did not parse: {e}"))
})?;
for ps_svc in services {
if let Some(name) = ps_svc.name {
if let Some(ref filter) = self.filter {
if !filter.iter().any(|f| name.contains(f)) {
continue;
}
}
let mut service = ServiceInfo::new(&name);
service.display_name = ps_svc.display_name;
service.service_type = ServiceType::Win32;
service.status = match ps_svc.status {
Some(1) => ServiceStatus::Stopped,
Some(2) => ServiceStatus::Starting,
Some(3) => ServiceStatus::Stopping,
Some(4) => ServiceStatus::Running,
_ => ServiceStatus::Unknown,
};
service.startup_type = match ps_svc.start_type {
Some(0) | Some(1) | Some(2) => StartupType::Automatic,
Some(3) => StartupType::Manual,
Some(4) => StartupType::Disabled,
_ => StartupType::Unknown,
};
service.enabled = ps_svc.start_type.map(|t| matches!(t, 0..=2));
let idx = self.services.len();
self.service_map.insert(name, idx);
self.services.push(service);
}
}
Ok(())
}
#[cfg(target_os = "windows")]
fn windows_start_service(&self, name: &str) -> Result<()> {
use std::process::Command;
let status = Command::new("sc").args(["start", name]).status();
match status {
Ok(s) if s.success() => Ok(()),
Ok(_) => Err(IronError::System(format!(
"Failed to start service '{}' (run as Administrator)",
name
))),
Err(e) => Err(IronError::System(format!("Failed to execute sc: {}", e))),
}
}
#[cfg(target_os = "windows")]
fn windows_stop_service(&self, name: &str) -> Result<()> {
use std::process::Command;
let status = Command::new("sc").args(["stop", name]).status();
match status {
Ok(s) if s.success() => Ok(()),
Ok(_) => Err(IronError::System(format!(
"Failed to stop service '{}' (run as Administrator)",
name
))),
Err(e) => Err(IronError::System(format!("Failed to execute sc: {}", e))),
}
}
#[cfg(target_os = "windows")]
fn windows_set_startup(&self, name: &str, startup: StartupType) -> Result<()> {
use std::process::Command;
let start_type = match startup {
StartupType::Automatic => "auto",
StartupType::Manual => "demand",
StartupType::Disabled => "disabled",
_ => "demand",
};
let status = Command::new("sc")
.args(["config", name, "start=", start_type])
.status();
match status {
Ok(s) if s.success() => Ok(()),
Ok(_) => Err(IronError::System(format!(
"Failed to configure service '{}' (run as Administrator)",
name
))),
Err(e) => Err(IronError::System(format!("Failed to execute sc: {}", e))),
}
}
#[cfg(target_os = "macos")]
fn macos_discover(&mut self) -> Result<()> {
use std::process::Command;
let output = Command::new("launchctl")
.args(["list"])
.output()
.map_err(|e| IronError::HardwareError(format!("launchctl: {e}")))?;
if !output.status.success() {
return Err(IronError::HardwareError(
"launchctl list failed".to_string(),
));
}
let stdout = String::from_utf8(output.stdout)
.map_err(|e| IronError::HardwareError(format!("launchctl output: {e}")))?;
for line in stdout.lines().skip(1) {
let parts: Vec<&str> = line.split_whitespace().collect();
if parts.len() >= 3 {
let name = parts[2].to_string();
if let Some(ref filter) = self.filter {
if !filter.iter().any(|f| name.contains(f)) {
continue;
}
}
let mut service = ServiceInfo::new(&name);
if let Ok(pid) = parts[0].parse::<u32>() {
service.pid = Some(pid);
service.status = ServiceStatus::Running;
} else if parts[0] == "-" {
service.status = ServiceStatus::Stopped;
}
if let Ok(code) = parts[1].parse::<i32>() {
service.exit_code = Some(code);
if code != 0 && service.status == ServiceStatus::Stopped {
service.status = ServiceStatus::Failed;
}
}
let idx = self.services.len();
self.service_map.insert(name, idx);
self.services.push(service);
}
}
Ok(())
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ServiceSummary {
pub total: usize,
pub running: usize,
pub stopped: usize,
pub failed: usize,
pub enabled: usize,
}
pub fn service_summary() -> Result<ServiceSummary> {
let monitor = ServiceMonitor::new()?;
let services = monitor.services();
Ok(ServiceSummary {
total: services.len(),
running: services
.iter()
.filter(|s| s.status == ServiceStatus::Running)
.count(),
stopped: services
.iter()
.filter(|s| s.status == ServiceStatus::Stopped)
.count(),
failed: services
.iter()
.filter(|s| s.status == ServiceStatus::Failed)
.count(),
enabled: services.iter().filter(|s| s.enabled == Some(true)).count(),
})
}
pub fn is_service_running(name: &str) -> Option<bool> {
ServiceMonitor::with_filter(vec![name.to_string()])
.ok()
.and_then(|monitor| monitor.is_active(name))
}
fn normalise_service_name(name: &str) -> &str {
name.strip_suffix(".service").unwrap_or(name)
}
pub fn get_services_status(names: Vec<&str>) -> Result<HashMap<String, ServiceStatus>> {
let filter: Vec<String> = names.iter().map(|s| s.to_string()).collect();
let monitor = ServiceMonitor::with_filter(filter)?;
let mut statuses = HashMap::new();
for name in names {
let status = monitor
.get_service(name)
.map(|s| s.status.clone())
.unwrap_or(ServiceStatus::NotFound);
statuses.insert(name.to_string(), status);
}
Ok(statuses)
}
pub fn common_services() -> Vec<&'static str> {
#[cfg(target_os = "linux")]
{
vec![
"sshd",
"docker",
"nginx",
"apache2",
"postgresql",
"mysql",
"redis",
"mongodb",
"NetworkManager",
"bluetooth",
"cups",
"cron",
"rsyslog",
"ufw",
]
}
#[cfg(target_os = "windows")]
{
vec![
"wuauserv", "BITS", "Spooler", "WinDefend", "Dhcp", "Dnscache", "EventLog", "W32Time", "AudioSrv", "LanmanServer", "LanmanWorkstation", "MpsSvc", ]
}
#[cfg(target_os = "macos")]
{
vec![
"com.apple.dock",
"com.apple.Finder",
"com.apple.loginwindow",
"com.apple.WindowServer",
"com.apple.SystemUIServer",
"com.apple.wifi.WiFiAgent",
"com.apple.bluetoothd",
]
}
#[cfg(not(any(target_os = "linux", target_os = "windows", target_os = "macos")))]
{
vec![]
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_service_info_new_defaults() {
let info = ServiceInfo::new("sshd");
assert_eq!(info.name, "sshd");
assert_eq!(info.status, ServiceStatus::Unknown);
assert_eq!(info.enabled, None);
assert!(info.dependencies.is_empty());
assert!(info.dependents.is_empty());
assert!(info.pid.is_none());
}
#[test]
fn test_service_info_is_active() {
let mut info = ServiceInfo::new("test");
assert!(!info.is_active());
info.status = ServiceStatus::Running;
assert!(info.is_active());
info.status = ServiceStatus::Stopped;
assert!(!info.is_active());
}
#[test]
fn test_service_info_is_failed() {
let mut info = ServiceInfo::new("test");
assert!(!info.is_failed());
info.status = ServiceStatus::Failed;
assert!(info.is_failed());
}
#[test]
fn test_service_status_display() {
assert_eq!(ServiceStatus::Running.to_string(), "running");
assert_eq!(ServiceStatus::Stopped.to_string(), "stopped");
assert_eq!(ServiceStatus::Starting.to_string(), "starting");
assert_eq!(ServiceStatus::Stopping.to_string(), "stopping");
assert_eq!(ServiceStatus::Failed.to_string(), "failed");
assert_eq!(ServiceStatus::Unknown.to_string(), "unknown");
assert_eq!(ServiceStatus::NotFound.to_string(), "not-found");
}
#[test]
fn test_startup_type_display() {
assert_eq!(StartupType::Automatic.to_string(), "automatic");
assert_eq!(StartupType::Manual.to_string(), "manual");
assert_eq!(StartupType::Disabled.to_string(), "disabled");
assert_eq!(StartupType::OnDemand.to_string(), "on-demand");
assert_eq!(StartupType::Unknown.to_string(), "unknown");
}
#[test]
fn test_service_info_serde_roundtrip() {
let info = ServiceInfo::new("nginx");
let json = serde_json::to_string(&info).unwrap();
let parsed: ServiceInfo = serde_json::from_str(&json).unwrap();
assert_eq!(parsed.name, "nginx");
assert_eq!(parsed.status, ServiceStatus::Unknown);
}
#[test]
fn test_normalise_service_name_strips_systemd_suffix() {
assert_eq!(normalise_service_name("sshd.service"), "sshd");
assert_eq!(normalise_service_name("sshd"), "sshd");
assert_eq!(normalise_service_name("com.apple.dock"), "com.apple.dock");
}
#[cfg(target_os = "linux")]
#[test]
fn test_systemd_exited_is_neither_running_nor_stopped() {
let monitor = ServiceMonitor {
services: Vec::new(),
service_map: HashMap::new(),
last_update: Instant::now(),
filter: None,
};
let exited = monitor
.linux_parse_service_line(concat!(
"systemd-remount-fs.service loaded active exited ",
"Remount Root and Kernel File Systems"
))
.unwrap();
assert_eq!(exited.status, ServiceStatus::Exited);
let odd = monitor
.linux_parse_service_line("foo.service loaded active reloading Foo")
.unwrap();
assert_eq!(odd.status, ServiceStatus::Unknown);
}
}