pub struct Core<T: EventHandler + Clone + Send + Sync + 'static> {
pub state: Arc<Mutex<T>>,
/* private fields */
}
Expand description
The core interface for the application layer to interface with the networking layer.
Fields§
§state: Arc<Mutex<T>>
The state of the application
Implementations§
source§impl<T: EventHandler + Clone + Send + Sync + 'static> Core<T>
impl<T: EventHandler + Clone + Send + Sync + 'static> Core<T>
sourcepub fn save_keypair_offline(&self, config_file_path: &str) -> bool
pub fn save_keypair_offline(&self, config_file_path: &str) -> bool
Serialize keypair to protobuf format and write to config file on disk. This could be useful for saving a keypair for future use when going offline.
It returns a boolean to indicate success of operation. Only key types other than RSA can be serialized to protobuf format and only a single keypair can be saved at a time.
sourcepub async fn send_to_network(
&mut self,
app_request: AppData
) -> Option<StreamId>
pub async fn send_to_network( &mut self, app_request: AppData ) -> Option<StreamId>
Send data to the network layer and recieve a unique StreamId
to track the request.
If the internal stream buffer is full, None
will be returned.
sourcepub async fn recv_from_network(&mut self, stream_id: StreamId) -> NetworkResult
pub async fn recv_from_network(&mut self, stream_id: StreamId) -> NetworkResult
Explicitly retrieve the reponse to a request sent to the network layer.
This function is decoupled from the Core::send_to_network()
method so as to prevent
blocking until the response is returned.
sourcepub async fn query_network(&mut self, request: AppData) -> NetworkResult
pub async fn query_network(&mut self, request: AppData) -> NetworkResult
Perform an atomic send
and recieve
to and from the network layer. This function is
atomic and blocks until the result of the request is returned from the network layer.
This function should mostly be used when the result of the request is needed immediately and delay can be condoned. It will still timeout if the delay exceeds the configured period.
If the internal buffer is full, it will return an error.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Core<T>
impl<T> !RefUnwindSafe for Core<T>
impl<T> Send for Core<T>
impl<T> Sync for Core<T>
impl<T> Unpin for Core<T>
impl<T> !UnwindSafe for Core<T>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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