pub struct TrustedDocumentStore { /* private fields */ }Expand description
Trusted document lookup store.
Implementations§
Source§impl TrustedDocumentStore
impl TrustedDocumentStore
Sourcepub fn from_manifest_file(
path: &Path,
mode: TrustedDocumentMode,
) -> Result<Self, TrustedDocumentError>
pub fn from_manifest_file( path: &Path, mode: TrustedDocumentMode, ) -> Result<Self, TrustedDocumentError>
Load from a JSON manifest file at startup.
§Errors
Returns an error if the file cannot be read or parsed.
Sourcepub fn from_documents(
documents: HashMap<String, String>,
mode: TrustedDocumentMode,
) -> Self
pub fn from_documents( documents: HashMap<String, String>, mode: TrustedDocumentMode, ) -> Self
Create an in-memory store from a pre-built document map (for testing).
Sourcepub fn disabled() -> Self
pub fn disabled() -> Self
A disabled store that passes all queries through (permissive, empty).
Sourcepub const fn mode(&self) -> TrustedDocumentMode
pub const fn mode(&self) -> TrustedDocumentMode
Returns the enforcement mode.
Sourcepub async fn document_count(&self) -> usize
pub async fn document_count(&self) -> usize
Returns the number of documents in the manifest.
Sourcepub async fn replace_documents(&self, documents: HashMap<String, String>)
pub async fn replace_documents(&self, documents: HashMap<String, String>)
Atomically replace the document map (used by hot-reload).
Sourcepub async fn resolve(
&self,
document_id: Option<&str>,
raw_query: Option<&str>,
) -> Result<String, TrustedDocumentError>
pub async fn resolve( &self, document_id: Option<&str>, raw_query: Option<&str>, ) -> Result<String, TrustedDocumentError>
Resolve a query from document_id and/or raw_query.
document_idpresent + found → return stored query body.document_idpresent + NOT found →DocumentNotFound.- No
document_idin strict mode →ForbiddenRawQuery. - No
document_idin permissive mode → returnraw_query.
§Errors
Returns TrustedDocumentError::DocumentNotFound if a document_id is given but not in the
store. Returns TrustedDocumentError::ForbiddenRawQuery if no document_id is provided
in strict mode, or if raw_query is also absent in permissive mode.
Auto Trait Implementations§
impl Freeze for TrustedDocumentStore
impl !RefUnwindSafe for TrustedDocumentStore
impl Send for TrustedDocumentStore
impl Sync for TrustedDocumentStore
impl Unpin for TrustedDocumentStore
impl UnsafeUnpin for TrustedDocumentStore
impl !UnwindSafe for TrustedDocumentStore
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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