pub struct Component {
pub id: usize,
/* private fields */
}
Fields§
§id: usize
Implementations§
source§impl Component
impl Component
sourcepub fn state(&self) -> ComponentState
pub fn state(&self) -> ComponentState
Retreive the current state of a Component
Examples
The initial state is ComponentState::New
let agent = Agent::default();
let stream = agent.add_stream();
let component = stream.add_component().unwrap();
assert_eq!(component.state(), ComponentState::New);
sourcepub fn receive_stream(&self) -> impl Stream<Item = Vec<u8>>
pub fn receive_stream(&self) -> impl Stream<Item = Vec<u8>>
Retrieve a Stream that produces data sent to this component from a peer
sourcepub async fn send(&self, data: &[u8]) -> Result<(), AgentError>
pub async fn send(&self, data: &[u8]) -> Result<(), AgentError>
Send data to the peer using the established communication channel