pub fn wrap<Dir: Directory>(directory: Dir) -> crate::Result<ManagedDirectory> {
        match directory.atomic_read(&MANAGED_FILEPATH) {
            Ok(data) => {
                let managed_files_json = String::from_utf8_lossy(&data);
                let managed_files: HashSet<PathBuf> = serde_json::from_str(&managed_files_json)
                    .map_err(|e| {
                        DataCorruption::new(
                            MANAGED_FILEPATH.to_path_buf(),
                            format!("Managed file cannot be deserialized: {:?}. ", e),
                        )
                    })?;
                Ok(ManagedDirectory {
                    directory: Box::new(directory),
                    meta_informations: Arc::new(RwLock::new(MetaInformation {
                        managed_paths: managed_files,
                    })),
                })
            }
            Err(OpenReadError::FileDoesNotExist(_)) => Ok(ManagedDirectory {
                directory: Box::new(directory),
                meta_informations: Arc::default(),
            }),
            io_err @ Err(OpenReadError::IoError { .. }) => Err(io_err.err().unwrap().into()),
            Err(OpenReadError::IncompatibleIndex(incompatibility)) => {
                // For the moment, this should never happen  `meta.json`
                // do not have any footer and cannot detect incompatibility.
                Err(crate::TantivyError::IncompatibleIndex(incompatibility))
            }
        }
    }
/// Wraps a directory as managed directory.
Wraps a directory as managed directory.
Wraps a directory as managed directory .
pub fn wrap<Dir: Directory>(directory: Dir) -> crate::Result<ManagedDirectory> {
        match directory.atomic_read(&MANAGED_FILEPATH) {
            Ok(data) => {
                let managed_files_json = String::from_utf8_lossy(&data);
                let managed_files: HashSet<PathBuf> = serde_json::from_str(&managed_files_json)
                    .map_err(|e| {
                        DataCorruption::new(
                            MANAGED_FILEPATH.to_path_buf(),
                            format!("Managed file cannot be deserialized: {:?}. ", e),
                        )
                    })?;
                Ok(ManagedDirectory {
                    directory: Box::new(directory),
                    meta_informations: Arc::new(RwLock::new(MetaInformation {
                        managed_paths: managed_files,
                    })),
                })
            }
            Err(OpenReadError::FileDoesNotExist(_)) => Ok(ManagedDirectory {
                directory: Box::new(directory),
                meta_informations: Arc::default(),
            }),
            io_err @ Err(OpenReadError::IoError { .. }) => Err(io_err.err().unwrap().into()),
            Err(OpenReadError::IncompatibleIndex(incompatibility)) => {
                // For the moment, this should never happen  `meta.json`
                // do not have any footer and cannot detect incompatibility.
                Err(crate::TantivyError::IncompatibleIndex(incompatibility))
            }
        }
    }
pub fn wrap < Dir : Directory > ( directory : Dir ) -> crate :: Result < ManagedDirectory > { match directory . atomic_read ( & MANAGED_FILEPATH ) { Ok ( data ) => { let managed_files_json = String :: from_utf8_lossy ( & data ) ; let managed_files : HashSet < PathBuf > = serde_json :: from_str ( & managed_files_json ) . map_err ( | e | { DataCorruption :: new ( MANAGED_FILEPATH . to_path_buf ( ) , format ! ( " " e ) , ) } ) ? ; Ok ( ManagedDirectory { directory : Box :: new ( directory ) , meta_informations : Arc :: new ( RwLock :: new ( MetaInformation { managed_paths : managed_files , } ) ) , } ) } Err ( OpenReadError :: FileDoesNotExist ( _ ) ) => Ok ( ManagedDirectory { directory : Box :: new ( directory ) , meta_informations : Arc :: default ( ) , } ) , io_err @ Err ( OpenReadError :: IoError { .. } ) => Err ( io_err . err ( ) . unwrap ( ) . into ( ) ) , Err ( OpenReadError :: IncompatibleIndex ( incompatibility ) ) => { // For the moment, this should never happen  `meta.json` // do not have any footer and cannot detect incompatibility. Err ( crate :: TantivyError :: IncompatibleIndex ( incompatibility ) ) } } }
Wraps a directory as managed directory.
Wraps a directory as managed directory .
directory
Dir
directory
Dir