#![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 Tabs {
#[behavior]
selected: Selection<String>,
}
let ui = Ui::new();
let tabs = ui.mount(Tabs { selected: Selection::new(SelectionMode::Single) }).label("Settings");
ui.agent().act("Settings select general")?;
assert_eq!(tabs.read(|t| t.selected.selected().to_vec()), Some(vec!["general".to_owned()]));
# Ok::<(), rust_use::agent::ActError>(())
```
"#
)]
#![cfg_attr(docsrs, feature(doc_cfg))]
pub use rust_use_core::{
ActionError, ActionRequest, ActionSpec, Args, Behavior, ChangeEvent, ChangeKind, ChangeSet,
ChangeSource, ComponentId, ComponentInfo, Decision, Describe, DragDrop, Field, Handle,
InvokeError, Key, List, Orientation, Page, ParamSpec, Popup, Press, Primitive, Query, Ref,
ResolveError, RovingFocus, Selection, SelectionMode, Subscription, Toggle, 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, 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};
#[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 = "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, Args, Behavior, ChangeSource, ComponentId, Decision, Describe,
DragDrop, Field, Handle, Key, List, Orientation, Page, ParamSpec, Popup, Press, Primitive,
Query, Ref, RovingFocus, Selection, SelectionMode, Toggle, Typeahead, Ui, Value,
};
#[cfg(feature = "gpui")]
pub use crate::{HandleExt, UiBinding, UiExt};
#[cfg(feature = "agent")]
pub use crate::{UiAgentExt, step};
}