pub struct MarkdownService;Expand description
Service for markdown validation and sanitisation.
Implementations§
Source§impl MarkdownService
impl MarkdownService
Sourcepub fn message_render(
&self,
metadata: &MessageMetadata,
body: &NonEmptyText,
corrects: Option<Uuid>,
) -> PatientResult<NonEmptyText>
pub fn message_render( &self, metadata: &MessageMetadata, body: &NonEmptyText, corrects: Option<Uuid>, ) -> PatientResult<NonEmptyText>
Validates and sanitises markdown content for coordination thread messages.
Constructs properly formatted markdown from message metadata and body content. Escapes markdown syntax in body to prevent unintended formatting whilst preserving readability.
Body escaping rules:
#at line start →\#(prevents headers)- Triple backticks →
\``` (prevents code blocks) - Standalone
---,***,___→ escaped (prevents horizontal rules)
Message format produced:
**Message ID:** <uuid>
**Timestamp:** <iso8601>
**Author ID:** <uuid>
**Author name:** <name>
**Author role:** <role>
**Corrects:** <uuid> (optional)
Body content here§Arguments
metadata- Message metadata containing ID, timestamp, and author detailsbody- User-provided content to be escaped (guaranteed non-empty by type)corrects- Optional UUID of message being corrected
§Returns
Formatted markdown message with metadata and escaped body content.
§Errors
Returns PatientError::InvalidInput if role serialization fails.
Sourcepub fn thread_render(&self, messages: &[Message]) -> PatientResult<NonEmptyText>
pub fn thread_render(&self, messages: &[Message]) -> PatientResult<NonEmptyText>
Renders multiple messages into a complete markdown thread.
Takes a collection of messages and renders them all to markdown format. Each message is rendered with its metadata and body, separated by horizontal rules. The thread starts with a level-1 header “# Thread”.
§Arguments
messages- Slice of messages to render
§Returns
Complete markdown content with all messages rendered and separated.
§Errors
Returns PatientError::InvalidInput if any message has an empty body.
Sourcepub fn thread_parse(&self, content: &str) -> PatientResult<Vec<Message>>
pub fn thread_parse(&self, content: &str) -> PatientResult<Vec<Message>>
Parses a markdown thread file into structured messages.
Reads a complete coordination thread from markdown format, splitting on horizontal
rules (---) to separate individual messages. Each message is parsed to extract
variables and body content with markdown escaping reversed. The thread-level
header (level-1) is ignored as it’s not part of individual messages.
Thread format expected:
# Thread Title
**Variable1:** Value1
**Variable2:** Value2
Body content here
---
**Variable1:** Value1
Next message
...§Arguments
content- Complete markdown content from messages.md file
§Returns
Vector of parsed Message structures with strong typing.
§Errors
Returns PatientError::InvalidInput if content cannot be parsed correctly.
Trait Implementations§
Source§impl Clone for MarkdownService
impl Clone for MarkdownService
Source§fn clone(&self) -> MarkdownService
fn clone(&self) -> MarkdownService
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MarkdownService
impl Debug for MarkdownService
Auto Trait Implementations§
impl Freeze for MarkdownService
impl RefUnwindSafe for MarkdownService
impl Send for MarkdownService
impl Sync for MarkdownService
impl Unpin for MarkdownService
impl UnwindSafe for MarkdownService
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request