//
// DO NOT EDIT. THIS FILE IS GENERATED FROM $SRCDIR/netwerk/base/nsINetworkInterface.idl
//
/// `interface nsINetworkInterface : nsISupports`
///
/// ```text
/// /**
/// * A snapshot of one network interface, from
/// * nsINetworkLinkService.networkInterfaces.
/// *
/// * Addresses are strings without prefix length or IPv6 zone (no "%en0").
/// * IPv4 uses dotted-quad form, IPv6 the compressed form of RFC 5952.
/// * Lists are unordered and may be empty.
/// *
/// */
/// ```
///
// The actual type definition for the interface. This struct has methods
// declared on it which will call through its vtable. You never want to pass
// this type around by value, always pass it behind a reference.
#[repr(C)]
pub struct nsINetworkInterface {
vtable: &'static nsINetworkInterfaceVTable,
/// This field is a phantomdata to ensure that the VTable type and any
/// struct containing it is not safe to send across threads by default, as
/// XPCOM is generally not threadsafe.
///
/// If this type is marked as [rust_sync], there will be explicit `Send` and
/// `Sync` implementations on this type, which will override the inherited
/// negative impls from `Rc`.
__nosync: ::std::marker::PhantomData<::std::rc::Rc<u8>>,
// Make the rust compiler aware that there might be interior mutability
// in what actually implements the interface. This works around UB
// introduced by https://github.com/llvm/llvm-project/commit/01859da84bad95fd51d6a03b08b60c660e642a4f
// that a rust lint would make blatantly obvious, but doesn't exist.
// This prevents optimizations, but those optimizations weren't available
// before rustc switched to LLVM 16, and they now cause problems because
// of the UB.
// Until there's a lint available to find all our UB, it's simpler to
// avoid the UB in the first place, at the cost of preventing optimizations
// in places that don't cause UB. But again, those optimizations weren't
// available before.
__maybe_interior_mutability: ::std::cell::UnsafeCell<[u8; 0]>,
}
// Implementing XpCom for an interface exposes its IID, which allows for easy
// use of the `.query_interface<T>` helper method. This also defines that
// method for nsINetworkInterface.
unsafe impl XpCom for nsINetworkInterface {
const IID: nsIID = nsID(0x1e3b9710, 0x9118, 0x4bc4,
[0xaf, 0x4e, 0x5c, 0xc1, 0x66, 0xd6, 0x47, 0x50]);
}
// We need to implement the RefCounted trait so we can be used with `RefPtr`.
// This trait teaches `RefPtr` how to manage our memory.
unsafe impl RefCounted for nsINetworkInterface {
#[inline]
unsafe fn addref(&self) {
self.AddRef();
}
#[inline]
unsafe fn release(&self) {
self.Release();
}
}
// This trait is implemented on all types which can be coerced to from nsINetworkInterface.
// It is used in the implementation of `fn coerce<T>`. We hide it from the
// documentation, because it clutters it up a lot.
#[doc(hidden)]
pub trait nsINetworkInterfaceCoerce {
/// Cheaply cast a value of this type from a `nsINetworkInterface`.
fn coerce_from(v: &nsINetworkInterface) -> &Self;
}
// The trivial implementation: We can obviously coerce ourselves to ourselves.
impl nsINetworkInterfaceCoerce for nsINetworkInterface {
#[inline]
fn coerce_from(v: &nsINetworkInterface) -> &Self {
v
}
}
impl nsINetworkInterface {
/// Cast this `nsINetworkInterface` to one of its base interfaces.
#[inline]
pub fn coerce<T: nsINetworkInterfaceCoerce>(&self) -> &T {
T::coerce_from(self)
}
}
// Every interface struct type implements `Deref` to its base interface. This
// causes methods on the base interfaces to be directly avaliable on the
// object. For example, you can call `.AddRef` or `.QueryInterface` directly
// on any interface which inherits from `nsISupports`.
impl ::std::ops::Deref for nsINetworkInterface {
type Target = nsISupports;
#[inline]
fn deref(&self) -> &nsISupports {
unsafe {
::std::mem::transmute(self)
}
}
}
// Ensure we can use .coerce() to cast to our base types as well. Any type which
// our base interface can coerce from should be coercable from us as well.
impl<T: nsISupportsCoerce> nsINetworkInterfaceCoerce for T {
#[inline]
fn coerce_from(v: &nsINetworkInterface) -> &Self {
T::coerce_from(v)
}
}
// This struct represents the interface's VTable. A pointer to a statically
// allocated version of this struct is at the beginning of every nsINetworkInterface
// object. It contains one pointer field for each method in the interface. In
// the case where we can't generate a binding for a method, we include a void
// pointer.
#[doc(hidden)]
#[repr(C)]
pub struct nsINetworkInterfaceVTable {
/// We need to include the members from the base interface's vtable at the start
/// of the VTable definition.
pub __base: nsISupportsVTable,
/* readonly attribute ACString name; */
pub GetName: unsafe extern "system" fn (this: *const nsINetworkInterface, aName: *mut ::nsstring::nsACString) -> ::nserror::nsresult,
/* readonly attribute ACString mac; */
pub GetMac: unsafe extern "system" fn (this: *const nsINetworkInterface, aMac: *mut ::nsstring::nsACString) -> ::nserror::nsresult,
/* readonly attribute Array<ACString> gwv4; */
pub GetGwv4: unsafe extern "system" fn (this: *const nsINetworkInterface, aGwv4: *mut thin_vec::ThinVec<::nsstring::nsCString>) -> ::nserror::nsresult,
/* readonly attribute Array<ACString> gwv6; */
pub GetGwv6: unsafe extern "system" fn (this: *const nsINetworkInterface, aGwv6: *mut thin_vec::ThinVec<::nsstring::nsCString>) -> ::nserror::nsresult,
/* readonly attribute Array<ACString> ipv4; */
pub GetIpv4: unsafe extern "system" fn (this: *const nsINetworkInterface, aIpv4: *mut thin_vec::ThinVec<::nsstring::nsCString>) -> ::nserror::nsresult,
/* readonly attribute Array<ACString> ipv6; */
pub GetIpv6: unsafe extern "system" fn (this: *const nsINetworkInterface, aIpv6: *mut thin_vec::ThinVec<::nsstring::nsCString>) -> ::nserror::nsresult,
}
// The implementations of the function wrappers which are exposed to rust code.
// Call these methods rather than manually calling through the VTable struct.
impl nsINetworkInterface {
/// ```text
/// /**
/// * System name on Linux, Android and macOS, e.g. "eth0" or "en0".
/// * Adapter friendly name on Windows, e.g. "Wi-Fi", in UTF-8.
/// */
/// ```
///
/// `readonly attribute ACString name;`
#[inline]
pub unsafe fn GetName(&self, aName: *mut ::nsstring::nsACString) -> ::nserror::nsresult {
((*self.vtable).GetName)(self, aName)
}
/// ```text
/// /**
/// * Hardware address as six lowercase hex bytes, e.g. "02:00:5e:10:00:01".
/// * Longer addresses are cut to six bytes, shorter ones padded with zeros.
/// * "00:00:00:00:00:00" when there is none, e.g. on a VPN tunnel.
/// */
/// ```
///
/// `readonly attribute ACString mac;`
#[inline]
pub unsafe fn GetMac(&self, aMac: *mut ::nsstring::nsACString) -> ::nserror::nsresult {
((*self.vtable).GetMac)(self, aMac)
}
/// ```text
/// /**
/// * Next hops of the default routes through this interface that have an
/// * IPv4 gateway, e.g. "192.168.1.1". Routes without a next hop, as on
/// * point-to-point VPNs, are not listed.
/// */
/// ```
///
/// `readonly attribute Array<ACString> gwv4;`
#[inline]
pub unsafe fn GetGwv4(&self, aGwv4: *mut thin_vec::ThinVec<::nsstring::nsCString>) -> ::nserror::nsresult {
((*self.vtable).GetGwv4)(self, aGwv4)
}
/// ```text
/// /**
/// * Next hops of the default routes through this interface that have an
/// * IPv6 gateway. Usually a link-local router address, e.g.
/// * "fe80::5a1d:d8ff:fe3c:ba90".
/// */
/// ```
///
/// `readonly attribute Array<ACString> gwv6;`
#[inline]
pub unsafe fn GetGwv6(&self, aGwv6: *mut thin_vec::ThinVec<::nsstring::nsCString>) -> ::nserror::nsresult {
((*self.vtable).GetGwv6)(self, aGwv6)
}
/// ```text
/// /**
/// * IPv4 addresses, link-local ones (169.254.0.0/16) included.
/// */
/// ```
///
/// `readonly attribute Array<ACString> ipv4;`
#[inline]
pub unsafe fn GetIpv4(&self, aIpv4: *mut thin_vec::ThinVec<::nsstring::nsCString>) -> ::nserror::nsresult {
((*self.vtable).GetIpv4)(self, aIpv4)
}
/// ```text
/// /**
/// * IPv6 addresses, link-local ones (fe80::/10) included.
/// */
/// ```
///
/// `readonly attribute Array<ACString> ipv6;`
#[inline]
pub unsafe fn GetIpv6(&self, aIpv6: *mut thin_vec::ThinVec<::nsstring::nsCString>) -> ::nserror::nsresult {
((*self.vtable).GetIpv6)(self, aIpv6)
}
}