pub struct Link {
pub node1_id: i32,
pub node2_id: i32,
pub type: i32,
pub iface1: Option<Interface>,
pub iface2: Option<Interface>,
pub options: Option<LinkOptions>,
pub network_id: i32,
pub label: String,
pub color: String,
}Fields§
§node1_id: i32§node2_id: i32§type: i32§iface1: Option<Interface>§iface2: Option<Interface>§options: Option<LinkOptions>§network_id: i32§label: String§color: StringImplementations§
Source§impl Link
impl Link
Sourcepub fn type(&self) -> Enum
pub fn type(&self) -> Enum
Returns the enum value of type, or the default if the field is set to an invalid enum value.
Examples found in repository?
examples/links-dump.rs (line 29)
6async fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let remote = env::var("REMOTE_CORE").unwrap_or_else(|_| "http://127.0.0.1:50051".into());
8 let mut client = Client::connect(remote).await?;
9
10 let response = client.get_sessions().await?;
11
12 // println!("RESPONSE={:?}", response);
13
14 if response.is_empty() {
15 eprintln!("No sessions found");
16 return Ok(());
17 }
18 let session_id = response[0].id;
19
20 let response = client.get_session(session_id).await?.unwrap();
21
22 //println!("RESPONSE={:#?}", response);
23 //println!("RESPONSE={:#?}", response.nodes);
24 //println!("RESPONSE={:#?}", response.location.unwrap());
25
26 let mut links = Vec::new();
27 for l in response.links {
28 //dbg!(&l);
29 if l.r#type() == coreemu::core::link_type::Enum::Wireless {
30 // smaller of node1_id and node2_id
31 let (n1, n2) = if l.node1_id < l.node2_id {
32 (l.node1_id, l.node2_id)
33 } else {
34 (l.node2_id, l.node1_id)
35 };
36 links.push(format!("{}-{}", n1, n2));
37 }
38 }
39 println!("{}", links.join(","));
40 Ok(())
41}Trait Implementations§
Source§impl Message for Link
impl Message for Link
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Returns the encoded length of the message without a length delimiter.
Source§fn encode<B>(&self, buf: &mut B) -> Result<(), EncodeError>
fn encode<B>(&self, buf: &mut B) -> Result<(), EncodeError>
Encodes the message to a buffer. Read more
Source§fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Encodes the message to a newly allocated buffer.
Source§fn encode_length_delimited<B>(&self, buf: &mut B) -> Result<(), EncodeError>
fn encode_length_delimited<B>(&self, buf: &mut B) -> Result<(), EncodeError>
Encodes the message with a length-delimiter to a buffer. Read more
Source§fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Encodes the message with a length-delimiter to a newly allocated buffer.
Source§fn decode<B>(buf: B) -> Result<Self, DecodeError>
fn decode<B>(buf: B) -> Result<Self, DecodeError>
Decodes an instance of the message from a buffer. Read more
Source§fn decode_length_delimited<B>(buf: B) -> Result<Self, DecodeError>
fn decode_length_delimited<B>(buf: B) -> Result<Self, DecodeError>
Decodes a length-delimited instance of the message from the buffer.
Source§fn merge<B>(&mut self, buf: B) -> Result<(), DecodeError>
fn merge<B>(&mut self, buf: B) -> Result<(), DecodeError>
Decodes an instance of the message from a buffer, and merges it into
self. Read moreSource§fn merge_length_delimited<B>(&mut self, buf: B) -> Result<(), DecodeError>
fn merge_length_delimited<B>(&mut self, buf: B) -> Result<(), DecodeError>
Decodes a length-delimited instance of the message from buffer, and
merges it into
self.impl StructuralPartialEq for Link
Auto Trait Implementations§
impl Freeze for Link
impl RefUnwindSafe for Link
impl Send for Link
impl Sync for Link
impl Unpin for Link
impl UnsafeUnpin for Link
impl UnwindSafe for Link
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request