fxbox / deprecated-taxonomy

This repository has moved.
https://github.com/fxbox/foxbox/
Mozilla Public License 2.0
0 stars 9 forks source link

[RFC] Higher-level AdapterManager #54

Open Yoric opened 8 years ago

Yoric commented 8 years ago

Spinoff from an idea by @mcav in #53.

We could rewrite the AdapterManager's channel API as follows:

/// A channel, which may have read/write capabilities.
pub struct Channel {
  id: Id<Channel>,
  kind: ChannelKind,
  service: Id<ServiceId>,
  pub properties: PropertyBag,
  pub fetch: Option<Box< Fn(FetchArgs) -> Result<Value, Error> + Sync + Send>>,
  pub send: Option<Box< Fn(SendArgs) -> Result<(), Error> + Sync + Send>>,
  pub watch: Option<Box< Fn(WatchArgs) -> Result<WatchGuard, Error> + Sync + Send>>,
  // Possibly more in the future.
}
impl Channel {
  /// Create an empty channel.
  pub fn new(id: &Id<Channel>, service: &Id<ServiceId>, kind: ChannelKind) -> Self;
}

impl AdapterManger {
  pub fn add_channel(channel: Channel) -> Result<(), Error>
}

Pros

Yoric commented 8 years ago

Cc @fabricedesre , @cr , @julienw , @dhylands , @azasypkin , @aosmond .