pub struct Session<T: Transport> {
pub peer: Peer,
/* private fields */
}Expand description
A peer together with its connection.
Fields§
§peer: PeerImplementations§
Source§impl<T: Transport> Session<T>
impl<T: Transport> Session<T>
pub fn new(peer: Peer, transport: T) -> Self
Initiator: make sure the other side holds the vocabulary digest,
sending it if asked. Returns true if it had to be transferred.
Sourcepub fn send(
&mut self,
digest: &str,
raw: &[u8],
policy: UnknownPolicy,
) -> Result<u64>
pub fn send( &mut self, digest: &str, raw: &[u8], policy: UnknownPolicy, ) -> Result<u64>
Initiator: encode raw, send it, and check the receipt. Returns the
number of units the other side decoded. Fails if the other side
decoded anything other than what this side’s decoder gives.
Sourcepub fn propose(
&mut self,
digest: &str,
additions: &[Vec<String>],
version: &str,
) -> Result<String>
pub fn propose( &mut self, digest: &str, additions: &[Vec<String>], version: &str, ) -> Result<String>
Initiator: extend a shared vocabulary on both sides. Each side applies the step itself; the digests must agree. Returns the new digest. Nothing changes locally if the other side refuses.
Sourcepub fn propose_signed(
&mut self,
digest: &str,
additions: &[Vec<String>],
version: &str,
sign: &dyn Fn(&mut Vocabulary) -> Result<()>,
) -> Result<String>
pub fn propose_signed( &mut self, digest: &str, additions: &[Vec<String>], version: &str, sign: &dyn Fn(&mut Vocabulary) -> Result<()>, ) -> Result<String>
Session::propose, vouching for the result. sign is given the
vocabulary this side derived, sealed, and adds its signatures to
it; they travel with the proposal, and the vocabulary held here
afterwards carries them. The protocol makes no signature itself.
Sourcepub fn query(&mut self, digest: &str, symbols: &[String]) -> Result<Option<u32>>
pub fn query(&mut self, digest: &str, symbols: &[String]) -> Result<Option<u32>>
Initiator: ask whether a symbol sequence is a token over there.
Sourcepub fn translate(
&mut self,
sequence: &TokenSequence,
to_digest: &str,
) -> Result<TokenSequence>
pub fn translate( &mut self, sequence: &TokenSequence, to_digest: &str, ) -> Result<TokenSequence>
Initiator: have the other side re-encode a sequence under another vocabulary it holds.
Auto Trait Implementations§
impl<T> !RefUnwindSafe for Session<T>
impl<T> !Sync for Session<T>
impl<T> !UnwindSafe for Session<T>
impl<T> Forget for Session<T>
impl<T> Freeze for Session<T>where
T: Freeze,
impl<T> Move for Session<T>
impl<T> Send for Session<T>where
T: Send,
impl<T> Unpin for Session<T>where
T: Unpin,
impl<T> UnsafeUnpin for Session<T>where
T: UnsafeUnpin,
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more