pub struct Intent<M>(/* private fields */);
Expand description
A structure that encapsulates a state machine and an expectation
It’s usually built with a builder that starts with Intent::of(machine)
.
Then you add an expectation:
ⓘ
Intent::of(machine).expect_delimiter("\n", 1024)
And then you may add a timeout (in form of “deadline” or “absolute time”):
ⓘ
Intent::of(machine).expect_bytes(100)
.deadline(scope.now() + Duration::new(10, 0))
Implementations§
Source§impl<M> Intent<M>
impl<M> Intent<M>
Sourcepub fn of(machine: M) -> IntentBuilder<M>
pub fn of(machine: M) -> IntentBuilder<M>
Start building the Intent object of the state machine
Sourcepub fn error(e: Box<dyn Error>) -> Self
pub fn error(e: Box<dyn Error>) -> Self
Notifies that we have protocol error and connection should be closed
Sourcepub fn deadline(self, deadline: Time) -> Intent<M>
pub fn deadline(self, deadline: Time) -> Intent<M>
Add/change the deadline
Note: if you skip this method on next return timeout will be reset. Which means this state machine may hang indefinitely.
Sourcepub fn deadline_opt(self, deadline: Option<Time>) -> Intent<M>
pub fn deadline_opt(self, deadline: Option<Time>) -> Intent<M>
Add/change the deadline as an optional value
Note this will reset timeout if deadline is None, not keep unchanged
Trait Implementations§
Auto Trait Implementations§
impl<M> Freeze for Intent<M>where
M: Freeze,
impl<M> !RefUnwindSafe for Intent<M>
impl<M> !Send for Intent<M>
impl<M> !Sync for Intent<M>
impl<M> Unpin for Intent<M>where
M: Unpin,
impl<M> !UnwindSafe for Intent<M>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more