pub struct CatalogService { /* private fields */ }Expand description
The catalog publisher and subscriber for an indexing database.
Implementations§
Source§impl CatalogService
impl CatalogService
Sourcepub fn new(
indexing: &IndexingService,
docs: &DocsEngine,
blobs: &BlobStore,
author: AuthorId,
) -> Self
pub fn new( indexing: &IndexingService, docs: &DocsEngine, blobs: &BlobStore, author: AuthorId, ) -> Self
Construct a catalog service using an existing indexing database.
pub const fn database(&self) -> &IndexingDatabase
pub const fn indexing(&self) -> &IndexingService
Sourcepub async fn create_catalog(&self, name: impl Into<String>) -> Result<Catalog>
pub async fn create_catalog(&self, name: impl Into<String>) -> Result<Catalog>
Create and register a catalog namespace.
§Errors
Returns an error if the namespace or its metadata cannot be created.
Sourcepub async fn create(&self, name: impl Into<String>) -> Result<Catalog>
pub async fn create(&self, name: impl Into<String>) -> Result<Catalog>
Create a catalog namespace. Alias for Self::create_catalog.
§Errors
Returns an error if the namespace or its metadata cannot be created.
Sourcepub async fn publish_folder(
&self,
catalog: &Catalog,
folder: &SyncwebFolder,
) -> Result<usize>
pub async fn publish_folder( &self, catalog: &Catalog, folder: &SyncwebFolder, ) -> Result<usize>
Publish all entries in a folder to a catalog.
The catalog contains searchable metadata and content hashes, not file contents. The folder’s existing document remains authoritative.
§Errors
Returns an error if folder entries or catalog records cannot be read or written.
Sourcepub async fn publish_folder_with_metadata(
&self,
catalog: &Catalog,
folder: &SyncwebFolder,
folder_name: impl Into<String>,
tags: &[String],
) -> Result<usize>
pub async fn publish_folder_with_metadata( &self, catalog: &Catalog, folder: &SyncwebFolder, folder_name: impl Into<String>, tags: &[String], ) -> Result<usize>
Publish all entries in a folder with a display name and search tags.
§Errors
Returns an error if folder entries or catalog records cannot be read or written.
Sourcepub async fn publish(
&self,
catalog: &Catalog,
folder: &SyncwebFolder,
) -> Result<usize>
pub async fn publish( &self, catalog: &Catalog, folder: &SyncwebFolder, ) -> Result<usize>
Publish a folder using its namespace as the display name.
§Errors
Returns an error if folder entries or catalog records cannot be read or written.
Sourcepub async fn ticket(
&self,
catalog: &Catalog,
endpoint: EndpointAddr,
writable: bool,
) -> Result<DocTicket>
pub async fn ticket( &self, catalog: &Catalog, endpoint: EndpointAddr, writable: bool, ) -> Result<DocTicket>
Create a read-only ticket for a catalog namespace.
§Errors
Returns an error if the catalog ticket cannot be created.
Sourcepub async fn subscribe(&self, ticket: DocTicket) -> Result<Catalog>
pub async fn subscribe(&self, ticket: DocTicket) -> Result<Catalog>
Subscribe to a catalog using its iroh-docs ticket.
Subscription starts document synchronization and keeps a background watcher which imports new records into the local FTS database.
§Errors
Returns an error if the ticket cannot be imported or synchronized.
Sourcepub async fn subscribe_catalog(&self, ticket: DocTicket) -> Result<Catalog>
pub async fn subscribe_catalog(&self, ticket: DocTicket) -> Result<Catalog>
Subscribe to a catalog. Alias for Self::subscribe.
§Errors
Returns an error if the ticket cannot be imported or synchronized.
Sourcepub async fn subscribe_namespace(
&self,
namespace_id: NamespaceId,
) -> Result<Catalog>
pub async fn subscribe_namespace( &self, namespace_id: NamespaceId, ) -> Result<Catalog>
Open and subscribe to a catalog namespace already available locally.
§Errors
Returns an error if the namespace is not available or cannot be synced.
Sourcepub async fn sync_catalog(&self, catalog: &Catalog) -> Result<usize>
pub async fn sync_catalog(&self, catalog: &Catalog) -> Result<usize>
Synchronize a catalog once and import all records currently available.
§Errors
Returns an error if document synchronization or record indexing fails.
Sourcepub async fn sync(&self, catalog: &Catalog) -> Result<usize>
pub async fn sync(&self, catalog: &Catalog) -> Result<usize>
Synchronize a catalog once. Alias for Self::sync_catalog.
§Errors
Returns an error if document synchronization or record indexing fails.
Sourcepub async fn index_catalog(&self, catalog: &Catalog) -> Result<usize>
pub async fn index_catalog(&self, catalog: &Catalog) -> Result<usize>
Import all currently available records from a catalog.
§Errors
Returns an error if catalog entries cannot be read or decoded.
Sourcepub fn search(&self, query: &str, limit: usize) -> Result<Vec<CatalogRecord>>
pub fn search(&self, query: &str, limit: usize) -> Result<Vec<CatalogRecord>>
Search records imported from all known catalogs.
§Errors
Returns an error if the FTS query is invalid.
Sourcepub fn search_fts(
&self,
query: &str,
limit: usize,
) -> Result<Vec<CatalogRecord>>
pub fn search_fts( &self, query: &str, limit: usize, ) -> Result<Vec<CatalogRecord>>
Search records imported from all known catalogs. Alias for Self::search.
§Errors
Returns an error if the FTS query is invalid.
Sourcepub fn unsubscribe(&self, namespace_id: NamespaceId) -> Result<()>
pub fn unsubscribe(&self, namespace_id: NamespaceId) -> Result<()>
Stop following a catalog and remove its local records.
§Errors
Returns an error if the catalog index cannot be removed.
Trait Implementations§
Source§impl Clone for CatalogService
impl Clone for CatalogService
Source§fn clone(&self) -> CatalogService
fn clone(&self) -> CatalogService
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for CatalogService
impl !UnwindSafe for CatalogService
impl Freeze for CatalogService
impl Send for CatalogService
impl Sync for CatalogService
impl Unpin for CatalogService
impl UnsafeUnpin for CatalogService
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more