(dir: &Path)
| 138 | } |
| 139 | |
| 140 | async fn handle_vendor(dir: &Path) -> Result<()> { |
| 141 | let vendor_conf = dir.join("vendor.toml"); |
| 142 | info!(path = ?vendor_conf, "Reading vendor configuration"); |
| 143 | let vendor_conf: VendorConfig = toml::from_str(&fs::read_to_string(vendor_conf)?)?; |
| 144 | info!(vendor_name = %vendor_conf.vendor.name, "Vendor loaded"); |
| 145 | |
| 146 | info!(id = %vendor_conf.vendor.id, "Upserting vendor"); |
| 147 | let _ = device_profile::upsert_vendor(device_profile::Vendor { |
| 148 | id: vendor_conf.vendor.id.into(), |
| 149 | name: vendor_conf.vendor.name.clone(), |
| 150 | vendor_id: vendor_conf.vendor.vendor_id, |
| 151 | ouis: fields::StringVec::new( |
| 152 | vendor_conf |
| 153 | .vendor |
| 154 | .ouis |
| 155 | .iter() |
| 156 | .map(|v| Some(v.clone())) |
| 157 | .collect(), |
| 158 | ), |
| 159 | metadata: fields::KeyValue::new(vendor_conf.vendor.metadata.clone()), |
| 160 | ..Default::default() |
| 161 | }) |
| 162 | .await?; |
| 163 | |
| 164 | handle_devices(dir, &vendor_conf.vendor).await?; |
| 165 | |
| 166 | Ok(()) |
| 167 | } |
| 168 | |
| 169 | async fn handle_devices(dir: &Path, vendor: &Vendor) -> Result<()> { |
| 170 | info!(id = %vendor.id, "Upserting vendor devices"); |
no test coverage detected