superdoc-sdk 2.25.0

Beta Rust SDK for the SuperDoc document runtime
Documentation
//! Explicit native executable configuration; provisioning is a separate step.
use superdoc_sdk::{generated::types::*, Client, HostMode, HostOptions, Result};
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<()> {
    let args: Vec<_> = std::env::args().collect();
    assert_eq!(
        args.len(),
        5,
        "usage: edit HOST cli|document INPUT.docx OUTPUT.docx"
    );
    let mut options = HostOptions::new(&args[1]);
    options.mode = if args[2] == "document" {
        HostMode::Document
    } else {
        HostMode::Cli
    };
    let client = Client::connect(options).await?;
    let result = async {
        let doc = client
            .open(&DocOpenParams::new().with_doc(args[3].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[4].clone()))
            .await?;
        doc.close(&DocCloseBoundParams::new()).await?;
        let reopened = client
            .open(&DocOpenParams::new().with_doc(args[4].clone()))
            .await?;
        assert!(reopened
            .api()
            .get_text(&DocGetTextBoundParams::new())
            .await?
            .contains(&marker));
        reopened.close(&DocCloseBoundParams::new()).await?;
        Ok(())
    }
    .await;
    client.shutdown().await?;
    result
}