pub struct ServedCatalog { /* private fields */ }Expand description
Canonical bytes of an assembled catalog that passed validate
with no error diagnostic, with what that assembly left out.
Implementations§
Source§impl ServedCatalog
impl ServedCatalog
Sourcepub fn omitted(&self) -> &[Omission]
pub fn omitted(&self) -> &[Omission]
Every entry record the assembly left out of the served bytes, with its reason.
Sourcepub fn next_expiry(&self) -> Option<Timestamp>
pub fn next_expiry(&self) -> Option<Timestamp>
The earliest expiry among the leases in the served bytes.
Sourcepub async fn assemble(
store: &dyn CatalogStore,
catalog: &CatalogId,
now: SystemTime,
) -> Result<Self, ColdStartError>
pub async fn assemble( store: &dyn CatalogStore, catalog: &CatalogId, now: SystemTime, ) -> Result<Self, ColdStartError>
Assembles the catalog from the store with assemble at now.
§Errors
Returns ColdStartError::Assemble for any AssembleError: a store failure, an error
diagnostic in the assembled document, or a document that is not canonicalisable.
§Examples
use turul_ai_catalog_lambda::ServedCatalog;
use turul_ai_catalog_storage::{CatalogId, InMemoryCatalogStore};
let store = InMemoryCatalogStore::new();
let catalog = CatalogId::new("default")?;
let served = ServedCatalog::assemble(&store, &catalog, std::time::SystemTime::now()).await?;Sourcepub async fn from_document(document: &AiCatalog) -> Result<Self, ColdStartError>
pub async fn from_document(document: &AiCatalog) -> Result<Self, ColdStartError>
Builds the served catalog from a caller-supplied document: import into an in-memory
store, then ServedCatalog::assemble. Reads no file and adds nothing to the document, so
a function that compiles its catalog in and the local server share this one path.
§Errors
Returns ColdStartError::Import when the document cannot be stored (for example it
carries a catalog signature), and ColdStartError::Assemble when the assembled
document has an error diagnostic.
§Examples
use turul_ai_catalog::parse::parse;
use turul_ai_catalog_lambda::ServedCatalog;
let document = parse(br#"{"specVersion":"1.0","entries":[{"identifier":"urn:air:example.com:mcp:weather","type":"application/mcp-server-card+json","url":"https://mcp.example.com/server-card.json"}]}"#)?;
let served = ServedCatalog::from_document(&document).await?;Trait Implementations§
Auto Trait Implementations§
impl Forget for ServedCatalog
impl Freeze for ServedCatalog
impl Move for ServedCatalog
impl RefUnwindSafe for ServedCatalog
impl Send for ServedCatalog
impl Sync for ServedCatalog
impl Unpin for ServedCatalog
impl UnsafeUnpin for ServedCatalog
impl UnwindSafe for ServedCatalog
Blanket Implementations§
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
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