Spaces:
Sleeping
Sleeping
Download apps/api/native/src/document/providers/factory.rs from s-eto-hub/firecrawl-api: direct link, hf CLI and curl.
- Browser
- Download file 1.12 kB
-
https://huggingface.co/spaces/s-eto-hub/firecrawl-api/resolve/main/apps/api/native/src/document/providers/factory.rs
- Command line
-
hf download hf://spaces/s-eto-hub/firecrawl-api/apps/api/native/src/document/providers/factory.rs
-
curl -L -o factory.rs https://huggingface.co/spaces/s-eto-hub/firecrawl-api/resolve/main/apps/api/native/src/document/providers/factory.rs
1.12 kB
| use super::doc::DocProvider; | |
| use super::docx::DocxProvider; | |
| use super::odt::OdtProvider; | |
| use super::rtf::RtfProvider; | |
| use super::DocumentProvider; | |
| use super::xlsx::XlsxProvider; | |
| use napi_derive::napi; | |
| pub enum DocumentType { | |
| Doc, | |
| Docx, | |
| Rtf, | |
| Odt, | |
| Xlsx, | |
| } | |
| pub struct ProviderFactory { | |
| doc_provider: DocProvider, | |
| docx_provider: DocxProvider, | |
| rtf_provider: RtfProvider, | |
| odt_provider: OdtProvider, | |
| xlsx_provider: XlsxProvider, | |
| } | |
| impl ProviderFactory { | |
| pub fn new() -> Self { | |
| Self { | |
| doc_provider: DocProvider::new(), | |
| docx_provider: DocxProvider::new(), | |
| rtf_provider: RtfProvider::new(), | |
| odt_provider: OdtProvider::new(), | |
| xlsx_provider: XlsxProvider::new(), | |
| } | |
| } | |
| pub fn get_provider(&self, doc_type: DocumentType) -> &dyn DocumentProvider { | |
| match doc_type { | |
| DocumentType::Doc => &self.doc_provider, | |
| DocumentType::Docx => &self.docx_provider, | |
| DocumentType::Rtf => &self.rtf_provider, | |
| DocumentType::Odt => &self.odt_provider, | |
| DocumentType::Xlsx => &self.xlsx_provider, | |
| } | |
| } | |
| } | |