superdoc-sdk 2.26.0-next.9

Rust SDK for the SuperDoc document runtime
Documentation
//! Explicit native executable configuration; provisioning is a separate step.
use superdoc_sdk::{generated::types::*, Client, HostOptions, Result};
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<()> {
    let args: Vec<_> = std::env::args().collect();
    assert_eq!(args.len(), 4, "usage: edit CLI INPUT.docx OUTPUT.docx");
    let client = Client::connect(HostOptions::new(&args[1])).await?;
    let result = async {
        let doc = client
            .open(&DocOpenParams::new().with_doc(args[2].clone()))
            .await?;
        let marker = "Rust SDK 😀 e\u{301} \u{2028} \u{2029} qualification".to_owned();
        doc.api()
            .insert(&DocInsertBoundParams::new().with_value(marker.clone()))
            .await?;
        assert!(doc
            .api()
            .get_text(&DocGetTextBoundParams::new())
            .await?
            .contains(&marker));
        doc.api()
            .save(&DocSaveBoundParams::new().with_out(args[3].clone()))
            .await?;
        doc.close(&DocCloseBoundParams::new()).await?;
        let reopened = client
            .open(&DocOpenParams::new().with_doc(args[3].clone()))
            .await?;
        assert!(reopened
            .api()
            .get_text(&DocGetTextBoundParams::new())
            .await?
            .contains(&marker));
        reopened.close(&DocCloseBoundParams::new()).await?;
        Ok(())
    }
    .await;
    client.shutdown().await?;
    result
}