#![cfg_attr(
all(feature = "macros", feature = "agent"),
doc = r#"
## Quick start
```
use rust_use::prelude::*;
/// A button that mutes audio.
#[derive(Primitive, Default)]
struct MuteButton {
#[agent(value)]
muted: bool,
}
#[actions]
impl MuteButton {
/// Mute or unmute.
fn toggle(&mut self) {
self.muted = !self.muted;
}
}
let ui = Ui::new();
let mute = ui.mount(MuteButton::default()).label("Mute");
// What an agent reads: one line per component, with the actions available right now.
let agent = ui.agent();
assert_eq!(
agent.snapshot().to_string(),
"rev 2\n@1 mute-button \"Mute\" =false !toggle"
);
// What an agent sends. The reply carries only what changed.
let reply = agent.act("Mute toggle")?;
assert!(reply.to_string().ends_with("@1 mute-button \"Mute\" =true !toggle"));
assert_eq!(mute.read(|m| m.muted), Some(true));
# Ok::<(), rust_use::agent::ActError>(())
```
## Behaviors
Reusable interaction logic embeds into a component with `#[behavior]`. Its state and actions merge
into the component's own, and its typed methods stay available to your code.
```
use rust_use::prelude::*;
/// Tabs along the top of a settings window.
#[derive(Primitive)]
#[primitive(no_actions)]
struct Settings {
#[behavior]
tabs: Tabs,
}
let ui = Ui::new();
let settings = ui.mount(Settings { tabs: Tabs::new(["general", "privacy"]) }).label("Settings");
ui.agent().act("Settings select privacy")?;
assert_eq!(settings.read(|s| s.tabs.is_visible("privacy")), Some(true));
# Ok::<(), rust_use::agent::ActError>(())
```
"#
)]
#![cfg_attr(docsrs, feature(doc_cfg))]
pub use rust_use_core::{
ActionError, ActionRequest, ActionSpec, Approvals, Args, Behavior, ChangeEvent, ChangeKind,
ChangeSet, ChangeSource, Combobox, ComponentId, ComponentInfo, Decision, Describe, DragDrop,
Field, Handle, InvokeError, Key, List, Orientation, Page, ParamSpec, PendingApproval, Popup,
Press, Primitive, Query, Range, Ref, ResolveError, RovingFocus, Selection, SelectionMode,
Subscription, Tabs, Toggle, Transfer, Tree, TreeRow, Tx, Typeahead, Ui, Value,
};
#[cfg(feature = "agent")]
pub use rust_use_agent as agent;
#[cfg(feature = "ipc")]
pub use rust_use_agent::ipc;
#[cfg(feature = "mcp")]
pub use rust_use_agent::mcp;
#[cfg(feature = "agent")]
pub use rust_use_agent::{
ActError, ActOutcome, Agent, Diff, QueryOutcome, Script, Snapshot, SnapshotMore,
SnapshotOptions, Step, UiAgentExt, step,
};
#[cfg(feature = "gpui")]
pub use rust_use_gpui as gpui;
#[cfg(feature = "gpui")]
pub use rust_use_gpui::{HandleExt, UiBinding, UiExt};
#[cfg(feature = "tauri")]
pub use rust_use_tauri::{self as tauri, PluginBuilder};
#[doc(hidden)]
pub mod __private {
pub use rust_use_core as core;
pub use serde_json;
}
#[cfg(feature = "macros")]
pub use rust_use_macros::{Primitive, actions};
pub mod prelude {
#[cfg(feature = "tauri")]
pub use crate::PluginBuilder;
#[cfg(feature = "macros")]
pub use crate::actions;
#[cfg(feature = "ipc")]
pub use crate::ipc::{
Client, Endpoint, IpcError, RequestLog, Server, ServerGuard, list_endpoints,
};
#[cfg(feature = "mcp")]
pub use crate::mcp::{Endpoint as McpEndpoint, McpError, McpServer};
pub use crate::{
ActionError, ActionSpec, Approvals, Args, Behavior, ChangeSource, Combobox, ComponentId,
Decision, Describe, DragDrop, Field, Handle, Key, List, Orientation, Page, ParamSpec,
PendingApproval, Popup, Press, Primitive, Query, Range, Ref, RovingFocus, Selection,
SelectionMode, Tabs, Toggle, Transfer, Tree, TreeRow, Tx, Typeahead, Ui, Value,
};
#[cfg(feature = "gpui")]
pub use crate::{HandleExt, UiBinding, UiExt};
#[cfg(feature = "agent")]
pub use crate::{Script, SnapshotOptions, UiAgentExt, step};
}