Struct libredr_common::connection::Connection
source · pub struct Connection {
uuid: Uuid,
stream: Stream,
description: String,
}
Expand description
Connection
with a random uuid
and human-readable description
Fields§
§uuid: Uuid
§stream: Stream
§description: String
Implementations§
source§impl Connection
impl Connection
sourcepub fn description(&self) -> &str
pub fn description(&self) -> &str
description
is read-only
async fn check_version(&mut self) -> Result<()>
sourcepub async fn from_stream(stream: Stream, description: String) -> Result<Self>
pub async fn from_stream(stream: Stream, description: String) -> Result<Self>
Construct Connection
with random UUID
sourcepub async fn from_config(config: &HashMap<String, String>) -> Result<Self>
pub async fn from_config(config: &HashMap<String, String>) -> Result<Self>
Construct Connection
by connecting to LibreDR server.
Return Error
if connection failed
§Examples
async {
let mut config = HashMap::new();
config.insert(String::from("connect"), string::from("127.0.0.1:9000"));
config.insert(String::from("unix"), string::from("false"));
config.insert(String::from("tls"), string::from("false"));
let connection = Connection::from_config(&config).await?;
}
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Connection
impl RefUnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl UnwindSafe for Connection
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
§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>
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.