harmos_runtime/operations/
streaming.rs1pub(super) use harmos_sdk::operations::streaming::RequestClaims;
15pub use harmos_sdk::operations::streaming::{StreamInput, StreamItem, StreamSettings};
16
17use std::sync::Arc;
21use crate::{Error, Result};
24use harmos_sdk::operations::streaming as portable;
25
26pub type StreamOutput<T> = portable::StreamOutput<T, Error>;
33pub type StreamPermit<'a, T> = portable::StreamPermit<'a, T, Error>;
34impl From<portable::Error> for Error {
43 fn from(error: portable::Error) -> Self {
44 match error {
45 portable::Error::Settings => {
46 Self::InvalidInput { field: "operation stream limits", reason: "capacity exceeds the semaphore claim limit" }
47 }
48 portable::Error::Capacity => Self::ResourceExhausted { resource: "operation stream bytes" },
49 portable::Error::Construction => {
50 Self::InvalidInput { field: "operation stream construction bound", reason: "constructed value exceeds its reserved bytes" }
51 }
52 portable::Error::Closed => Self::NotReady { domain: "operation stream input" },
53 portable::Error::Ownership => {
54 Self::InvalidInput { field: "operation stream payload", reason: "original owned payload cannot be moved into a request" }
55 }
56 portable::Error::Codec(source) => Self::TaskFailed { domain: "operation stream decode", source: Arc::new(source) },
57 }
58 }
59}
60pub fn stream<T>(settings: StreamSettings) -> Result<(StreamOutput<T>, StreamInput<T>)> {
63 portable::channel(settings)
64}
65