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