pub struct RelationType {
pub rel: String,
pub from_kinds: BTreeSet<String>,
pub to_kinds: BTreeSet<String>,
pub description: Option<String>,
}Fields§
§rel: String§from_kinds: BTreeSet<String>§to_kinds: BTreeSet<String>§description: Option<String>Implementations§
Source§impl RelationType
impl RelationType
Sourcepub fn new(rel: impl Into<String>) -> Self
pub fn new(rel: impl Into<String>) -> Self
Examples found in repository?
examples/typed_pack.rs (line 16)
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 from_kind(self, kind: impl Into<String>) -> Self
pub fn from_kind(self, kind: impl Into<String>) -> Self
Examples found in repository?
examples/typed_pack.rs (line 17)
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 to_kind(self, kind: impl Into<String>) -> Self
pub fn to_kind(self, kind: impl Into<String>) -> Self
Examples found in repository?
examples/typed_pack.rs (line 18)
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 RelationType
impl Clone for RelationType
Source§fn clone(&self) -> RelationType
fn clone(&self) -> RelationType
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 RelationType
impl Debug for RelationType
Source§impl<'de> Deserialize<'de> for RelationType
impl<'de> Deserialize<'de> for RelationType
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 RelationType
Source§impl PartialEq for RelationType
impl PartialEq for RelationType
Source§fn eq(&self, other: &RelationType) -> bool
fn eq(&self, other: &RelationType) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for RelationType
impl Serialize for RelationType
impl StructuralPartialEq for RelationType
Auto Trait Implementations§
impl Freeze for RelationType
impl RefUnwindSafe for RelationType
impl Send for RelationType
impl Sync for RelationType
impl Unpin for RelationType
impl UnsafeUnpin for RelationType
impl UnwindSafe for RelationType
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