pub struct ObjectType {
pub kind: String,
pub required_props: BTreeSet<String>,
pub description: Option<String>,
}Fields§
§kind: String§required_props: BTreeSet<String>§description: Option<String>Implementations§
Source§impl ObjectType
impl ObjectType
Sourcepub fn new(kind: impl Into<String>) -> Self
pub fn new(kind: impl Into<String>) -> Self
Examples found in repository?
examples/typed_pack.rs (line 13)
8async fn main() -> Result<(), Box<dyn std::error::Error>> {
9 let state = YoAgentState::load(MemoryEventStore::new()).await?;
10 let mut runtime = YoAgentRuntime::new(state.clone());
11 runtime.register_pack(
12 Pack::new(PackId::new("pack_lineage"), "lineage", "0.1.0")
13 .add_object_type(ObjectType::new("goal").require("title"))
14 .add_object_type(ObjectType::new("task").require("title"))
15 .add_relation_type(
16 RelationType::new("serves")
17 .from_kind("task")
18 .to_kind("goal"),
19 ),
20 );
21
22 runtime
23 .create_typed_node(
24 ActorRef::agent("demo"),
25 NodeId::new("goal_1"),
26 "goal",
27 json!({ "title": "Improve retry reliability" }),
28 )
29 .await?;
30 runtime
31 .create_typed_node(
32 ActorRef::agent("demo"),
33 NodeId::new("task_1"),
34 "task",
35 json!({ "title": "Investigate timeout" }),
36 )
37 .await?;
38 runtime
39 .create_typed_relation(
40 ActorRef::agent("demo"),
41 NodeId::new("task_1"),
42 "serves",
43 NodeId::new("goal_1"),
44 json!({}),
45 )
46 .await?;
47
48 println!("{}", serde_json::to_string_pretty(&state.graph().await)?);
49 Ok(())
50}Sourcepub fn require(self, prop: impl Into<String>) -> Self
pub fn require(self, prop: impl Into<String>) -> Self
Examples found in repository?
examples/typed_pack.rs (line 13)
8async fn main() -> Result<(), Box<dyn std::error::Error>> {
9 let state = YoAgentState::load(MemoryEventStore::new()).await?;
10 let mut runtime = YoAgentRuntime::new(state.clone());
11 runtime.register_pack(
12 Pack::new(PackId::new("pack_lineage"), "lineage", "0.1.0")
13 .add_object_type(ObjectType::new("goal").require("title"))
14 .add_object_type(ObjectType::new("task").require("title"))
15 .add_relation_type(
16 RelationType::new("serves")
17 .from_kind("task")
18 .to_kind("goal"),
19 ),
20 );
21
22 runtime
23 .create_typed_node(
24 ActorRef::agent("demo"),
25 NodeId::new("goal_1"),
26 "goal",
27 json!({ "title": "Improve retry reliability" }),
28 )
29 .await?;
30 runtime
31 .create_typed_node(
32 ActorRef::agent("demo"),
33 NodeId::new("task_1"),
34 "task",
35 json!({ "title": "Investigate timeout" }),
36 )
37 .await?;
38 runtime
39 .create_typed_relation(
40 ActorRef::agent("demo"),
41 NodeId::new("task_1"),
42 "serves",
43 NodeId::new("goal_1"),
44 json!({}),
45 )
46 .await?;
47
48 println!("{}", serde_json::to_string_pretty(&state.graph().await)?);
49 Ok(())
50}Trait Implementations§
Source§impl Clone for ObjectType
impl Clone for ObjectType
Source§fn clone(&self) -> ObjectType
fn clone(&self) -> ObjectType
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 Debug for ObjectType
impl Debug for ObjectType
Source§impl<'de> Deserialize<'de> for ObjectType
impl<'de> Deserialize<'de> for ObjectType
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for ObjectType
Source§impl PartialEq for ObjectType
impl PartialEq for ObjectType
Source§fn eq(&self, other: &ObjectType) -> bool
fn eq(&self, other: &ObjectType) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for ObjectType
impl Serialize for ObjectType
impl StructuralPartialEq for ObjectType
Auto Trait Implementations§
impl Freeze for ObjectType
impl RefUnwindSafe for ObjectType
impl Send for ObjectType
impl Sync for ObjectType
impl Unpin for ObjectType
impl UnsafeUnpin for ObjectType
impl UnwindSafe for ObjectType
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