pub struct RichDocumentModel { /* private fields */ }Implementations§
Source§impl RichDocumentModel
impl RichDocumentModel
pub fn new() -> RichDocumentModel
Sourcepub fn from_markdown(markdown: impl Into<String>) -> RichDocumentModel
pub fn from_markdown(markdown: impl Into<String>) -> RichDocumentModel
Examples found in repository?
examples/rich_document.rs (lines 5-19)
3fn main() -> Result<()> {
4 let theme = DefaultTheme::dark();
5 let document = RichDocumentModel::from_markdown(
6 r#"# Deployment report
7
8SUI keeps this document selectable across blocks. Follow the [runbook](https://example.test/runbook) for details.
9
10- [x] Build artifacts
11- [x] Run tests
12- [ ] Publish release
13
14```rust
15let status = deploy().await?;
16assert!(status.ready());
17```
18"#,
19 );
20
21 let mut operation = RichExtensionBlock::new("operation-log", "Release operation");
22 operation.status = RichDocumentStatus::Running;
23 operation.summary = Some("2 of 3 stages complete".into());
24 operation.body = "build complete\ntest complete\npublish running".into();
25 document.append_extension(operation);
26
27 let view = RichDocumentView::new(document)
28 .theme(theme)
29 .on_link(|destination| println!("Application URL policy received: {destination}"));
30 let root = Surface::window(ScrollView::vertical(view).retain_content_layer())
31 .theme(theme)
32 .padding(Insets::all(24.0))
33 .fill();
34
35 App::new()
36 .window(Window::new("SUI Rich Document").root(root))
37 .run()
38}pub fn revision(&self) -> u64
pub fn markdown(&self) -> String
pub fn blocks(&self) -> Vec<RichDocumentBlock>
pub fn snapshot(&self) -> RichDocumentSnapshot
pub fn last_update(&self) -> RichDocumentUpdate
pub fn set_markdown(&self, markdown: impl Into<String>) -> bool
Sourcepub fn append_markdown(&self, fragment: &str) -> bool
pub fn append_markdown(&self, fragment: &str) -> bool
Append a streaming Markdown fragment and reparse only the mutable tail.
All blocks before the final Markdown block are retained byte-for-byte, including their stable IDs and any widget-local state keyed by them.
pub fn append_attachment(&self, attachment: RichAttachment) -> RichBlockId
Sourcepub fn append_extension(&self, extension: RichExtensionBlock) -> RichBlockId
pub fn append_extension(&self, extension: RichExtensionBlock) -> RichBlockId
Examples found in repository?
examples/rich_document.rs (line 25)
3fn main() -> Result<()> {
4 let theme = DefaultTheme::dark();
5 let document = RichDocumentModel::from_markdown(
6 r#"# Deployment report
7
8SUI keeps this document selectable across blocks. Follow the [runbook](https://example.test/runbook) for details.
9
10- [x] Build artifacts
11- [x] Run tests
12- [ ] Publish release
13
14```rust
15let status = deploy().await?;
16assert!(status.ready());
17```
18"#,
19 );
20
21 let mut operation = RichExtensionBlock::new("operation-log", "Release operation");
22 operation.status = RichDocumentStatus::Running;
23 operation.summary = Some("2 of 3 stages complete".into());
24 operation.body = "build complete\ntest complete\npublish running".into();
25 document.append_extension(operation);
26
27 let view = RichDocumentView::new(document)
28 .theme(theme)
29 .on_link(|destination| println!("Application URL policy received: {destination}"));
30 let root = Surface::window(ScrollView::vertical(view).retain_content_layer())
31 .theme(theme)
32 .padding(Insets::all(24.0))
33 .fill();
34
35 App::new()
36 .window(Window::new("SUI Rich Document").root(root))
37 .run()
38}pub fn update_structured( &self, id: RichBlockId, kind: RichDocumentBlockKind, ) -> bool
Trait Implementations§
Source§impl Clone for RichDocumentModel
impl Clone for RichDocumentModel
Source§fn clone(&self) -> RichDocumentModel
fn clone(&self) -> RichDocumentModel
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for RichDocumentModel
impl Default for RichDocumentModel
Source§fn default() -> RichDocumentModel
fn default() -> RichDocumentModel
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for RichDocumentModel
impl RefUnwindSafe for RichDocumentModel
impl Send for RichDocumentModel
impl Sync for RichDocumentModel
impl Unpin for RichDocumentModel
impl UnsafeUnpin for RichDocumentModel
impl UnwindSafe for RichDocumentModel
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
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.