pub struct Router<N>where
N: Nomenclature,{ /* private fields */ }Expand description
Generic router consisting of a queue of routing extensions, implementing specific router logic
Implementations§
Source§impl<N> Router<N>where
N: Nomenclature + 'static,
impl<N> Router<N>where
N: Nomenclature + 'static,
Sourcepub fn new(
extensions: impl IntoIterator<Item = Box<dyn RouterExtension<N>>>,
) -> Self
pub fn new( extensions: impl IntoIterator<Item = Box<dyn RouterExtension<N>>>, ) -> Self
Constructs router with all used extensions
pub fn extensions(&self) -> Iter<'_, N, Box<dyn RouterExtension<N>>>
pub fn extensions_mut(&mut self) -> IterMut<'_, N, Box<dyn RouterExtension<N>>>
Sourcepub fn add_extension(&mut self, extension: Box<dyn RouterExtension<N>>)
pub fn add_extension(&mut self, extension: Box<dyn RouterExtension<N>>)
Adds new extension to the router.
pub fn compute_route( &mut self, payment: PaymentRequest, ) -> Vec<Hop<N::HopPayload>>
Trait Implementations§
Source§impl<N> Extension<N> for Router<N>where
N: Nomenclature + Nomenclature,
impl<N> Extension<N> for Router<N>where
N: Nomenclature + Nomenclature,
fn identity(&self) -> N
Source§fn state_change(
&mut self,
request: &<N as Nomenclature>::UpdateRequest,
message: &mut <N as Nomenclature>::PeerMessage,
) -> Result<(), <N as Nomenclature>::Error>
fn state_change( &mut self, request: &<N as Nomenclature>::UpdateRequest, message: &mut <N as Nomenclature>::PeerMessage, ) -> Result<(), <N as Nomenclature>::Error>
Perform a sate change and produce a message which should be communicated
to peers notifying them about the state change
Source§fn update_from_local(
&mut self,
message: &<N as Nomenclature>::UpdateMessage,
) -> Result<(), <N as Nomenclature>::Error>
fn update_from_local( &mut self, message: &<N as Nomenclature>::UpdateMessage, ) -> Result<(), <N as Nomenclature>::Error>
Updates extension state from some local data
Source§fn update_from_peer(
&mut self,
message: &<N as Nomenclature>::PeerMessage,
) -> Result<(), <N as Nomenclature>::Error>
fn update_from_peer( &mut self, message: &<N as Nomenclature>::PeerMessage, ) -> Result<(), <N as Nomenclature>::Error>
Updates extension state from the data taken from the message received
from the remote peer
fn load_state(&mut self, state: &N::State)
fn store_state(&self, state: &mut N::State)
Source§impl<N> RouterExtension<N> for Router<N>where
N: Nomenclature + 'static,
impl<N> RouterExtension<N> for Router<N>where
N: Nomenclature + 'static,
Source§fn new() -> Box<dyn RouterExtension<N>>where
Self: Sized,
fn new() -> Box<dyn RouterExtension<N>>where
Self: Sized,
Constructs boxed extension objects which can be inserted into router
extension pipeline
fn build_route( &mut self, payment: PaymentRequest, route: &mut Vec<Hop<N::HopPayload>>, )
Source§impl<N> StrictDecode for Router<N>
impl<N> StrictDecode for Router<N>
Source§fn strict_decode<D: Read>(d: D) -> Result<Self, Error>
fn strict_decode<D: Read>(d: D) -> Result<Self, Error>
Decode with the given
std::io::Read instance; must either
construct an instance or return implementation-specific error type.Source§fn strict_deserialize(data: impl AsRef<[u8]>) -> Result<Self, Error>
fn strict_deserialize(data: impl AsRef<[u8]>) -> Result<Self, Error>
Tries to deserialize byte array into the current type using
StrictDecode::strict_decode. If there are some data remains in the
buffer once deserialization is completed, fails with
Error::DataNotEntirelyConsumed. Use io::Cursor over the buffer and
StrictDecode::strict_decode to avoid such failures.Source§fn strict_file_load(path: impl AsRef<Path>) -> Result<Self, Error>
fn strict_file_load(path: impl AsRef<Path>) -> Result<Self, Error>
Reads data from file at
path and reconstructs object from it. Fails
with Error::DataNotEntirelyConsumed if file contains remaining
data after the object reconstruction.Source§impl<N> StrictEncode for Router<N>
impl<N> StrictEncode for Router<N>
Source§fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>
fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>
Encode with the given
std::io::Write instance; must return result
with either amount of bytes encoded – or implementation-specific
error type.Source§fn strict_serialize(&self) -> Result<Vec<u8>, Error>
fn strict_serialize(&self) -> Result<Vec<u8>, Error>
Serializes data as a byte array using
StrictEncode::strict_encode
functionAuto Trait Implementations§
impl<N> Freeze for Router<N>
impl<N> !RefUnwindSafe for Router<N>
impl<N> !Send for Router<N>
impl<N> !Sync for Router<N>
impl<N> Unpin for Router<N>
impl<N> !UnwindSafe for Router<N>
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