post_archiver/importer/platform.rs
1use crate::{
2 manager::{PostArchiverConnection, PostArchiverManager},
3 PlatformId,
4};
5
6impl<T> PostArchiverManager<T>
7where
8 T: PostArchiverConnection,
9{
10 /// Import a platform into the archive.
11 ///
12 /// If the platform already exists, it returns the existing ID.
13 ///
14 /// # Errors
15 ///
16 /// Returns `rusqlite::Error` if there was an error accessing the database.
17 pub fn import_platform(&self, platform: String) -> Result<PlatformId, rusqlite::Error> {
18 match self.find_platform(&platform)? {
19 Some(id) => Ok(id),
20 None => self.add_platform(platform),
21 }
22 }
23}