spoke/core
Types
A command to be performed, as requested by the user of the client.
pub type Command {
  SubscribeToUpdates(drift.Effect(mqtt.Update))
  UnsubscribeFromUpdates(drift.Effect(mqtt.Update))
  Connect(
    clean_session: Bool,
    will: option.Option(mqtt.PublishData),
  )
  Disconnect(drift.Effect(Nil))
  Subscribe(
    List(mqtt.SubscribeRequest),
    drift.Effect(
      Result(List(mqtt.Subscription), mqtt.OperationError),
    ),
  )
  Unsubscribe(
    List(String),
    drift.Effect(Result(Nil, mqtt.OperationError)),
  )
  PublishMessage(mqtt.PublishData)
  GetPendingPublishes(drift.Effect(Int))
  WaitForPublishesToFinish(
    drift.Effect(Result(Nil, mqtt.OperationError)),
    Int,
  )
}
      
      Constructors
- 
          
SubscribeToUpdates(drift.Effect(mqtt.Update))Registers an effect to be invoked when updates are available.
 - 
          
UnsubscribeFromUpdates(drift.Effect(mqtt.Update))Unregisters an effect from being invoked on updates.
 - 
          
Connect( clean_session: Bool, will: option.Option(mqtt.PublishData), )Starts connecting to the borker.
 - 
          
Disconnect(drift.Effect(Nil))Disconnects from the broker
 - 
          
Subscribe( List(mqtt.SubscribeRequest), drift.Effect( Result(List(mqtt.Subscription), mqtt.OperationError), ), )Starts a subscribing to topics.
 - 
          
Unsubscribe( List(String), drift.Effect(Result(Nil, mqtt.OperationError)), )Starts unsubscribing from topics.
 - 
          
PublishMessage(mqtt.PublishData)Starts publishing a message.
 - 
          
GetPendingPublishes(drift.Effect(Int))Requests for the number of in-progress publishes.
 - 
          
WaitForPublishesToFinish( drift.Effect(Result(Nil, mqtt.OperationError)), Int, )Starts waiting for publishes to finish.
 
Type alias for the drift context.
pub type Context =
  drift.Context(Input, Output)
      
    The union of all the possible inputs
pub type Input {
  Perform(Command)
  Handle(TransportEvent)
  Timeout(TimedAction)
}
      
      Constructors
- 
          
Perform(Command) - 
          
Handle(TransportEvent) - 
          
Timeout(TimedAction) 
All the outputs (side effects)
pub type Output {
  Publish(drift.Action(mqtt.Update))
  OpenTransport
  CloseTransport
  SendData(bytes_tree.BytesTree)
  ReturnPendingPublishes(drift.Action(Int))
  PublishesCompleted(
    drift.Action(Result(Nil, mqtt.OperationError)),
  )
  SubscribeCompleted(
    drift.Action(
      Result(List(mqtt.Subscription), mqtt.OperationError),
    ),
  )
  UnsubscribeCompleted(
    drift.Action(Result(Nil, mqtt.OperationError)),
  )
  CompleteDisconnect(drift.Action(Nil))
  UpdatePersistedSession(session_state.StorageUpdate)
}
      
      Constructors
- 
          
Publish(drift.Action(mqtt.Update))Publish an update the user of the client.
 - 
          
OpenTransportOpen the transport channel.
 - 
          
CloseTransportClose the transport channel.
 - 
          
SendData(bytes_tree.BytesTree)Send data to the transport channel.
 - 
          
ReturnPendingPublishes(drift.Action(Int))Publish the result for the count of pending publishes.
 - 
          
PublishesCompleted( drift.Action(Result(Nil, mqtt.OperationError)), )Waiting for publishes completed.
 - 
          
SubscribeCompleted( drift.Action( Result(List(mqtt.Subscription), mqtt.OperationError), ), )Subscribing to topics completed.
 - 
          
UnsubscribeCompleted( drift.Action(Result(Nil, mqtt.OperationError)), )Unsubscribing from topics completed.
 - 
          
CompleteDisconnect(drift.Action(Nil))A disconnect request completed.
 - 
          
UpdatePersistedSession(session_state.StorageUpdate)Apply an update to a persisted session.
 
An action that happens as a result of timer expiring
pub opaque type TimedAction
      
    An event coming from the transport channel
pub type TransportEvent {
  TransportEstablished
  TransportFailed(String)
  TransportClosed
  ReceivedData(BitArray)
}
      
      Constructors
- 
          
TransportEstablishedThe transport channel is open, and ready to receive data.
 - 
          
TransportFailed(String)The transport channel failed for some reason.
 - 
          
TransportClosedThe transport channel was closed after requesting it.
 - 
          
ReceivedData(BitArray)Data was received on the transport channel.
 
Values
pub fn handle_input(
  context: drift.Context(Input, Output),
  state: State,
  input: Input,
) -> drift.Step(State, Input, Output, String)
    
    Runs one step, handing the given input.
pub fn restore_state(
  options: mqtt.ConnectOptions(a),
  state: session_state.SessionState,
) -> State
    
    Creates a new state from an existing session.