docbox-processing 0.7.2

Docbox file processing logic
Documentation
use docbox_processing::{
    ProcessingLayer, ProcessingLayerConfig,
    office::{OfficeConverter, OfficeProcessingLayer, convert_server::OfficeConverterServer},
};
use testcontainers::{
    ContainerAsync, GenericImage,
    core::{IntoContainerPort, WaitFor, wait::HttpWaitStrategy},
    runners::AsyncRunner,
};

/// Create a test container for the office convert server
pub async fn test_office_convert_server_container() -> ContainerAsync<GenericImage> {
    GenericImage::new("jacobtread/office-convert-server", "0.2.2")
        .with_exposed_port(3000.tcp())
        .with_wait_for(WaitFor::seconds(5))
        .with_wait_for(WaitFor::http(
            HttpWaitStrategy::new("/status").with_expected_status_code(200u16),
        ))
        .start()
        .await
        .unwrap()
}

/// Create a processing layer from the provided office convert server container
pub async fn test_processing_layer(
    container: &ContainerAsync<GenericImage>,
    config: ProcessingLayerConfig,
) -> ProcessingLayer {
    let host = container.get_host().await.unwrap();
    let host_port = container.get_host_port_ipv4(3000).await.unwrap();
    let client_url = format!("http://{host}:{host_port}");

    let converter_server =
        OfficeConverterServer::from_addresses([client_url.as_str()], false).unwrap();
    let converter = OfficeConverter::ConverterServer(converter_server);

    ProcessingLayer {
        office: OfficeProcessingLayer { converter },
        config,
    }
}