pub struct Peer { /* private fields */ }Expand description
One side of the protocol.
Implementations§
Source§impl Peer
impl Peer
pub fn new(name: &str, engine: Engine, policy: Policy) -> Self
Sourcepub fn require_vocabulary_check(&mut self, check: VocabularyCheck)
pub fn require_vocabulary_check(&mut self, check: VocabularyCheck)
Take a vocabulary from the other side only if check passes it.
Vocabularies this side adds itself are not checked: their holder
chose them. While a check is set, proposals are refused, since a
vocabulary derived here from a proposal is one nobody has vouched
for.
Sourcepub fn add_vocabulary(&mut self, vocabulary: Vocabulary) -> Result<String>
pub fn add_vocabulary(&mut self, vocabulary: Vocabulary) -> Result<String>
Hold vocabulary. Returns its digest.
pub fn vocabulary(&self, digest: &str) -> Option<&Vocabulary>
pub fn digests(&self) -> Vec<String>
Sourcepub fn take_inbox(&mut self) -> Vec<Delivered>
pub fn take_inbox(&mut self) -> Vec<Delivered>
Messages received and decoded since the last call.
pub fn engine(&self) -> &Engine
pub fn hello(&self) -> Message
pub fn capabilities(&self) -> Message
Sourcepub fn encode_message(
&self,
id: u64,
digest: &str,
raw: &[u8],
policy: UnknownPolicy,
) -> Result<(Message, String)>
pub fn encode_message( &self, id: u64, digest: &str, raw: &[u8], policy: UnknownPolicy, ) -> Result<(Message, String)>
Encode raw under a held vocabulary and wrap it as a message.
Returns the message and the SHA-256 the receiver’s ACK must carry.
Sourcepub fn evolve(
&mut self,
digest: &str,
additions: &[Vec<String>],
version: &str,
) -> Result<String>
pub fn evolve( &mut self, digest: &str, additions: &[Vec<String>], version: &str, ) -> Result<String>
Apply an evolution step to a held vocabulary and hold the result.
Sourcepub fn translate(
&self,
sequence: &TokenSequence,
to_digest: &str,
) -> Result<TokenSequence>
pub fn translate( &self, sequence: &TokenSequence, to_digest: &str, ) -> Result<TokenSequence>
Re-encode a sequence under another held vocabulary. Symbols the target lacks are escaped, so nothing is lost.
Auto Trait Implementations§
impl !RefUnwindSafe for Peer
impl !Sync for Peer
impl !UnwindSafe for Peer
impl Forget for Peer
impl Freeze for Peer
impl Move for Peer
impl Send for Peer
impl Unpin for Peer
impl UnsafeUnpin for Peer
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
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> ⓘ
Converts
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> ⓘ
Converts
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