repo stringlengths 6 65 | file_url stringlengths 81 311 | file_path stringlengths 6 227 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:31:58 2026-01-04 20:25:31 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/async_device/unix/mod.rs | src/async_device/unix/mod.rs | #[cfg(all(target_os = "linux", not(target_env = "ohos")))]
use crate::platform::offload::{handle_gro, VirtioNetHdr, VIRTIO_NET_HDR_LEN};
use crate::platform::DeviceImpl;
#[cfg(all(target_os = "linux", not(target_env = "ohos")))]
use crate::platform::GROTable;
use crate::SyncDevice;
use std::io;
use std::io::{IoSlice, I... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/async_device/unix/tokio.rs | src/async_device/unix/tokio.rs | use std::io;
use std::task::{Context, Poll};
use crate::platform::DeviceImpl;
use ::tokio::io::unix::AsyncFd as TokioAsyncFd;
use ::tokio::io::Interest;
/// An async Tun/Tap device wrapper around a Tun/Tap device.
///
/// This type does not provide a split method, because this functionality can be achieved by instead... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/async_device/unix/async_io.rs | src/async_device/unix/async_io.rs | use crate::platform::DeviceImpl;
use ::async_io::Async;
use std::io;
use std::task::{Context, Poll};
/// An async Tun/Tap device wrapper around a Tun/Tap device.
///
/// This type does not provide a split method, because this functionality can be achieved by instead wrapping the socket in an Arc.
///
/// # Streams
///... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/async_device/windows/mod.rs | src/async_device/windows/mod.rs | use crate::platform::windows::{ffi, InterruptEvent};
use crate::platform::DeviceImpl;
use crate::SyncDevice;
use std::future::Future;
use std::io;
use std::ops::Deref;
use std::os::windows::io::{AsRawHandle, OwnedHandle};
use std::pin::Pin;
use std::sync::{Arc, Mutex};
use std::task::{Context, Poll};
/// An async Tun/... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/async_device/macos/select_io.rs | src/async_device/macos/select_io.rs | use crate::DeviceImpl;
use std::cmp::Ordering;
use std::future::Future;
use std::io;
use std::io::{IoSlice, IoSliceMut};
use std::ops::Deref;
use std::os::fd::AsRawFd;
use std::pin::Pin;
use std::sync::{Arc, Mutex};
use std::task::{Context, Poll};
use std::time::Duration;
pub(crate) struct NonBlockingDevice {
devi... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/async_device/macos/mod.rs | src/async_device/macos/mod.rs | use crate::async_device::unix;
use crate::{DeviceImpl, SyncDevice};
use std::io;
use std::io::{IoSlice, IoSliceMut};
use std::ops::Deref;
use std::os::fd::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
use std::task::{Context, Poll};
mod select_io;
/// An async Tun/Tap device wrapper around a Tun/Tap device.
///
/// This typ... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/mod.rs | src/platform/mod.rs | #[cfg(unix)]
pub(crate) mod unix;
#[cfg(all(
unix,
not(any(
target_os = "windows",
target_os = "macos",
all(target_os = "linux", not(target_env = "ohos")),
target_os = "freebsd",
target_os = "openbsd",
target_os = "netbsd",
))
))]
pub use self::unix::DeviceIm... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/unix/fd.rs | src/platform/unix/fd.rs | use std::io;
use std::io::{IoSlice, IoSliceMut};
use std::os::unix::io::{AsRawFd, IntoRawFd, RawFd};
use libc::{self, fcntl, F_GETFL, O_NONBLOCK};
/// POSIX file descriptor support for `io` traits.
pub(crate) struct Fd {
pub(crate) inner: RawFd,
borrow: bool,
}
impl Fd {
#[cfg(any(
target_os = "w... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/unix/device.rs | src/platform/unix/device.rs | use crate::platform::unix::{Fd, Tun};
use crate::platform::DeviceImpl;
#[cfg(any(
all(target_os = "linux", not(target_env = "ohos")),
target_os = "macos",
target_os = "freebsd",
target_os = "openbsd",
target_os = "netbsd",
))]
use libc::{AF_INET, AF_INET6, SOCK_DGRAM};
use std::io;
use std::io::{IoS... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/unix/mod.rs | src/platform/unix/mod.rs | mod sockaddr;
#[cfg(any(
all(target_os = "linux", not(target_env = "ohos")),
target_os = "freebsd",
target_os = "openbsd",
target_os = "netbsd",
target_os = "macos"
))]
pub(crate) use sockaddr::sockaddr_union;
#[cfg(any(
all(target_os = "linux", not(target_env = "ohos")),
target_os = "macos... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/unix/interrupt.rs | src/platform/unix/interrupt.rs | use crate::platform::unix::Fd;
use std::io;
use std::io::{IoSlice, IoSliceMut};
use std::os::fd::AsRawFd;
use std::sync::Mutex;
impl Fd {
pub(crate) fn read_interruptible(
&self,
buf: &mut [u8],
event: &InterruptEvent,
timeout: Option<std::time::Duration>,
) -> io::Result<usize>... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/unix/sockaddr.rs | src/platform/unix/sockaddr.rs | /// # Safety
unsafe fn sockaddr_to_rs_addr(sa: &sockaddr_union) -> Option<std::net::SocketAddr> {
match sa.addr_stor.ss_family as libc::c_int {
libc::AF_INET => {
let sa_in = sa.addr4;
let ip = std::net::Ipv4Addr::from(sa_in.sin_addr.s_addr.to_ne_bytes());
let port = u16:... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/unix/tun.rs | src/platform/unix/tun.rs | use crate::platform::unix::Fd;
#[cfg(any(
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "openbsd",
target_os = "freebsd",
target_os = "netbsd",
))]
use crate::PACKET_INFORMATION_LENGTH as PIL;
use std::io::{self, IoSlice, IoSliceMut};
use std::os::unix::io::{AsRawFd, In... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/openbsd/device.rs | src/platform/openbsd/device.rs | use crate::{
builder::{DeviceConfig, Layer},
platform::openbsd::sys::*,
platform::{
unix::{sockaddr_union, Fd, Tun},
ETHER_ADDR_LEN,
},
ToIpv4Address, ToIpv4Netmask, ToIpv6Address, ToIpv6Netmask,
};
use crate::platform::unix::device::{ctl, ctl_v6};
use libc::{self, c_char, c_short, ... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/openbsd/mod.rs | src/platform/openbsd/mod.rs | mod sys;
mod device;
pub use self::device::DeviceImpl;
| rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/openbsd/sys.rs | src/platform/openbsd/sys.rs | use libc::{c_char, c_int, c_uint, ifreq, sockaddr, sockaddr_in6, time_t, IFNAMSIZ};
use nix::{ioctl_readwrite, ioctl_write_ptr};
use std::ffi::c_void;
pub const IN6_IFF_NODAD: i32 = 0x0020;
#[allow(dead_code)]
#[allow(non_camel_case_types)]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ctl_info {
pub ctl_id: c_uin... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/linux/device.rs | src/platform/linux/device.rs | use crate::platform::linux::offload::{
gso_none_checksum, gso_split, handle_gro, VirtioNetHdr, VIRTIO_NET_HDR_F_NEEDS_CSUM,
VIRTIO_NET_HDR_GSO_NONE, VIRTIO_NET_HDR_GSO_TCPV4, VIRTIO_NET_HDR_GSO_TCPV6,
VIRTIO_NET_HDR_GSO_UDP_L4, VIRTIO_NET_HDR_LEN,
};
use crate::platform::unix::device::{ctl, ctl_v6};
use cra... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | true |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/linux/checksum.rs | src/platform/linux/checksum.rs | use byteorder::{BigEndian, ByteOrder};
/// A pure Rust scalar (non-SIMD) implementation for the checksum accumulation.
///
/// It uses a simple loop instead of manual unrolling for better clarity and maintainability.
fn checksum_no_fold_scalar(mut b: &[u8], initial: u64) -> u64 {
let mut accumulator = initial;
... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/linux/mod.rs | src/platform/linux/mod.rs | mod sys;
mod checksum;
mod device;
pub(crate) mod offload;
pub use device::DeviceImpl;
pub use offload::ExpandBuffer;
pub use offload::GROTable;
pub use offload::IDEAL_BATCH_SIZE;
pub use offload::VIRTIO_NET_HDR_LEN;
| rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/linux/offload.rs | src/platform/linux/offload.rs | /// https://github.com/WireGuard/wireguard-go/blob/master/tun/offload_linux.go
use crate::platform::linux::checksum::{checksum, pseudo_header_checksum_no_fold};
use byteorder::{BigEndian, ByteOrder};
use bytes::BytesMut;
use libc::{IPPROTO_TCP, IPPROTO_UDP};
use std::collections::HashMap;
use std::io;
/// https://gith... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | true |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/linux/sys.rs | src/platform/linux/sys.rs | use libc::{c_int, ifreq, in6_ifreq};
use nix::{ioctl_read, ioctl_read_bad, ioctl_write_ptr, ioctl_write_ptr_bad};
ioctl_read_bad!(siocgifflags, 0x8913, ifreq);
ioctl_write_ptr_bad!(siocsifflags, 0x8914, ifreq);
ioctl_read_bad!(siocgifaddr, 0x8915, ifreq);
ioctl_write_ptr_bad!(siocsifaddr, 0x8916, ifreq);
ioctl_write_p... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/windows/netsh.rs | src/platform/windows/netsh.rs | use std::io;
use std::net::IpAddr;
use std::os::windows::process::CommandExt;
use std::process::{Command, Output};
use encoding_rs::GBK;
use windows_sys::Win32::System::Threading::CREATE_NO_WINDOW;
pub fn set_interface_name(old_name: &str, new_name: &str) -> io::Result<()> {
let cmd = format!(" netsh interface se... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/windows/device.rs | src/platform/windows/device.rs | use crate::builder::DeviceConfig;
use crate::platform::windows::netsh;
use crate::platform::windows::tap::TapDevice;
use crate::platform::windows::tun::{check_adapter_if_orphaned_devices, TunDevice};
use crate::platform::ETHER_ADDR_LEN;
use crate::{Layer, ToIpv4Address, ToIpv4Netmask, ToIpv6Address, ToIpv6Netmask};
use... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/windows/ffi.rs | src/platform/windows/ffi.rs | use std::os::windows::io::{FromRawHandle, OwnedHandle, RawHandle};
use std::{io, mem, ptr};
use windows_sys::Win32::Foundation::{ERROR_IO_PENDING, NO_ERROR};
use windows_sys::Win32::NetworkManagement::IpHelper::{
GetIpInterfaceTable, MIB_IPINTERFACE_ROW, MIB_IPINTERFACE_TABLE,
};
use windows_sys::Win32::Networking... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/windows/mod.rs | src/platform/windows/mod.rs | mod device;
pub(crate) mod ffi;
#[cfg(any(
feature = "interruptible",
feature = "async_tokio",
feature = "async_io"
))]
mod interrupt;
mod netsh;
mod tap;
mod tun;
#[cfg(any(
feature = "interruptible",
feature = "async_tokio",
feature = "async_io"
))]
pub use interrupt::InterruptEvent;
pub use ... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/windows/interrupt.rs | src/platform/windows/interrupt.rs | use crate::platform::windows::ffi;
use std::io;
use std::os::windows::io::{AsRawHandle, OwnedHandle};
use std::sync::Mutex;
pub struct InterruptEvent {
pub(crate) handle: OwnedHandle,
state: Mutex<i32>,
}
impl InterruptEvent {
pub fn new() -> io::Result<Self> {
Ok(Self {
handle: ffi::cr... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/windows/tun/bindings_i686.rs | src/platform/windows/tun/bindings_i686.rs | /* automatically generated by rust-bindgen 0.72.0 */
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct __BindgenBitfieldUnit<Storage> {
storage: Storage,
}
impl<Storage> __BindgenBitfieldUnit<Storage> {
#[inline]
pub const fn new(storage: Storage) -> Self {
... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/windows/tun/adapter.rs | src/platform/windows/tun/adapter.rs | use std::{io, mem, ptr};
use crate::windows::{
device::GUID_NETWORK_ADAPTER,
ffi::{decode_utf16, destroy_device_info_list, encode_utf16, enum_device_info},
};
use windows_sys::Win32::Foundation::INVALID_HANDLE_VALUE;
use windows_sys::Win32::Foundation::{DEVPROPKEY, ERROR_INSUFFICIENT_BUFFER};
use windows_sys::... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/windows/tun/adapter_win7.rs | src/platform/windows/tun/adapter_win7.rs | use std::{mem, ptr};
use windows_sys::Win32::Devices::DeviceAndDriverInstallation::{
SetupDiGetClassDevsExW, SetupDiGetDevicePropertyW,
};
use windows_sys::Win32::Devices::Properties::DEVPROP_TYPE_BINARY;
use windows_sys::Win32::Foundation::{
CloseHandle, GetLastError, ERROR_INVALID_DATA, FILETIME, INVALID_HAND... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/windows/tun/mod.rs | src/platform/windows/tun/mod.rs | use std::os::windows::io::{AsRawHandle, OwnedHandle};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex, MutexGuard, RwLock};
use std::{io, ptr};
use windows_sys::core::GUID;
use windows_sys::Win32::Foundation::{
GetLastError, ERROR_BUFFER_OVERFLOW, ERROR_HANDLE_EOF, ERROR_INVALID_DATA, ERRO... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/windows/tun/wintun_raw.rs | src/platform/windows/tun/wintun_raw.rs | #![allow(warnings)]
#[cfg(all(not(docsrs), feature = "bindgen"))]
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
#[cfg(any(docsrs, not(feature = "bindgen")))]
#[cfg(target_pointer_width = "64")]
include!("bindings_x86_64.rs");
#[cfg(any(docsrs, not(feature = "bindgen")))]
#[cfg(target_pointer_width = "32")]
inc... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/windows/tun/bindings_x86_64.rs | src/platform/windows/tun/bindings_x86_64.rs | /* automatically generated by rust-bindgen 0.72.0 */
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct __BindgenBitfieldUnit<Storage> {
storage: Storage,
}
impl<Storage> __BindgenBitfieldUnit<Storage> {
#[inline]
pub const fn new(storage: Storage) -> Self {
... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/windows/tun/wintun_log.rs | src/platform/windows/tun/wintun_log.rs | #![allow(dead_code)]
use log::*;
use crate::platform::windows::tun::wintun_raw;
use widestring::U16CStr;
/// Sets the logger wintun will use when logging. Maps to the WintunSetLogger C function
pub fn set_logger(win_tun: &wintun_raw::wintun, f: wintun_raw::WINTUN_LOGGER_CALLBACK) {
unsafe { win_tun.WintunSetLogge... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/windows/tap/overlapped.rs | src/platform/windows/tap/overlapped.rs | use crate::platform::windows::ffi;
use crate::platform::windows::tap::READ_BUFFER_SIZE;
use bytes::BytesMut;
use std::io;
use std::os::windows::io::{AsRawHandle, OwnedHandle};
use std::sync::Arc;
use windows_sys::Win32::System::Threading::{WaitForMultipleObjects, INFINITE};
use windows_sys::Win32::System::IO::OVERLAPPE... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/windows/tap/iface.rs | src/platform/windows/tap/iface.rs | use crate::platform::windows::device::GUID_NETWORK_ADAPTER;
use crate::platform::windows::ffi;
use crate::platform::windows::ffi::decode_utf16;
use scopeguard::{guard, ScopeGuard};
use std::io;
use std::os::windows::io::{FromRawHandle, OwnedHandle};
use std::process::Command;
use windows_sys::Win32::Storage::FileSystem... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/windows/tap/mod.rs | src/platform/windows/tap/mod.rs | use crate::platform::windows::tap::overlapped::{ReadOverlapped, WriteOverlapped};
use crate::platform::windows::{ffi, netsh};
use std::os::windows::io::{AsRawHandle, OwnedHandle};
use std::sync::{Arc, Mutex};
use std::{io, time};
use windows_sys::Win32::Foundation::HANDLE;
use windows_sys::Win32::NetworkManagement::Ndi... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/macos/device.rs | src/platform/macos/device.rs | use crate::{
builder::DeviceConfig,
platform::{macos::sys::*, unix::sockaddr_union},
ToIpv4Address, ToIpv4Netmask, ToIpv6Address, ToIpv6Netmask,
};
//const OVERWRITE_SIZE: usize = std::mem::size_of::<libc::__c_anonymous_ifr_ifru>();
use crate::platform::macos::tuntap::TunTap;
use crate::platform::unix::de... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/macos/tuntap.rs | src/platform/macos/tuntap.rs | use crate::builder::DeviceConfig;
use crate::platform::macos::sys::{
ctl_info, ctliocginfo, in6_ifreq, siocgiflladdr, siocsiflladdr, siocsifmtu, IN6_IFF_NODAD,
UTUN_CONTROL_NAME,
};
use crate::platform::macos::tap::Tap;
use crate::platform::unix::device::ctl;
use crate::platform::unix::Tun;
use crate::platform:... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/macos/mod.rs | src/platform/macos/mod.rs | mod sys;
mod device;
mod tap;
mod tuntap;
pub use self::device::DeviceImpl;
| rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/macos/sys.rs | src/platform/macos/sys.rs | use std::{ffi::c_void, os::raw::c_int};
use libc::{c_char, c_short, c_uint, ifreq, sockaddr, sockaddr_in6, time_t, IFNAMSIZ};
use nix::{ioctl_readwrite, ioctl_write_ptr};
pub const UTUN_CONTROL_NAME: &str = "com.apple.net.utun_control";
pub const IN6_IFF_NODAD: i32 = 0x0020;
#[allow(non_camel_case_types)]
#[repr(C)]... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/macos/tap/mod.rs | src/platform/macos/tap/mod.rs | /*
link https://github.com/apple-oss-distributions/xnu/blob/main/bsd/sys/sockio.h
link https://github.com/apple-oss-distributions/xnu/blob/main/bsd/net/if_fake.c
link https://www.zerotier.com/blog/how-zerotier-eliminated-kernel-extensions-on-macos/
*/
/*
* link https://github.com/zerotier/ZeroTierOne/blob/dev/osdep/Ma... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/freebsd/device.rs | src/platform/freebsd/device.rs | use crate::{
builder::{DeviceConfig, Layer},
platform::freebsd::sys::*,
platform::{
unix::{sockaddr_union, Fd, Tun},
ETHER_ADDR_LEN,
},
ToIpv4Address, ToIpv4Netmask, ToIpv6Address, ToIpv6Netmask,
};
use crate::platform::unix::device::{ctl, ctl_v6};
use libc::{
self, c_char, c_sh... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/freebsd/mod.rs | src/platform/freebsd/mod.rs | mod sys;
mod device;
pub use self::device::DeviceImpl;
| rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/freebsd/sys.rs | src/platform/freebsd/sys.rs | use libc::{c_char, c_int, c_uint, ifreq, sockaddr, sockaddr_in6, time_t, IFNAMSIZ};
use nix::{ioctl_readwrite, ioctl_write_ptr};
use std::ffi::c_void;
//pub const IN6_IFF_NODAD: i32 = 0x0020;
pub const IN6_IFF_NODAD: i32 = 0x100;
pub const ND6_IFF_AUTO_LINKLOCAL: i32 = 0x20;
#[allow(dead_code)]
#[allow(non_camel_case... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/netbsd/device.rs | src/platform/netbsd/device.rs | use crate::{
builder::{DeviceConfig, Layer},
platform::netbsd::sys::*,
platform::{
unix::{sockaddr_union, Fd, Tun},
ETHER_ADDR_LEN,
},
ToIpv4Address, ToIpv4Netmask, ToIpv6Address, ToIpv6Netmask,
};
use crate::platform::unix::device::{ctl, ctl_v6};
use libc::{self, c_char, c_short, A... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/netbsd/mod.rs | src/platform/netbsd/mod.rs | mod sys;
mod device;
pub use self::device::DeviceImpl;
| rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/src/platform/netbsd/sys.rs | src/platform/netbsd/sys.rs | use libc::{c_char, c_int, c_uint, sockaddr, sockaddr_in6, sockaddr_storage, time_t, IFNAMSIZ};
use nix::{ioctl_read, ioctl_readwrite, ioctl_write_ptr};
use std::ffi::c_void;
// https://github.com/justincormack/netbsd-src/blob/master/src/sys/sys/sockio.h
// https://github.com/justincormack/netbsd-src/blob/master/src/sy... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/tests/test_dev.rs | tests/test_dev.rs | #![allow(unused_imports)]
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::sync::Arc;
use std::time::Duration;
use pnet_packet::ip::IpNextHeaderProtocols;
use pnet_packet::Packet;
#[cfg(any(
target_os = "windows",
target_os = "macos",
all(target_os = "linux", not(target_env = "ohos")),
... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/examples/write.rs | examples/write.rs | #[allow(unused_imports)]
use std::net::Ipv4Addr;
#[allow(unused_imports)]
use std::sync::{mpsc::Receiver, Arc};
#[allow(unused_imports)]
#[cfg(any(
target_os = "windows",
all(target_os = "linux", not(target_env = "ohos")),
target_os = "macos",
target_os = "freebsd",
target_os = "openbsd",
))]
use tu... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/examples/named_tun.rs | examples/named_tun.rs | #[allow(unused_imports)]
use std::net::Ipv4Addr;
use std::sync::mpsc::Receiver;
#[allow(unused_imports)]
use std::sync::Arc;
#[allow(unused_imports)]
#[cfg(any(
target_os = "windows",
all(target_os = "linux", not(target_env = "ohos")),
target_os = "freebsd",
target_os = "macos",
target_os = "openbs... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/examples/async_tap.rs | examples/async_tap.rs | #![allow(unused_imports)]
use pnet_packet::ethernet::{EtherTypes, EthernetPacket};
use pnet_packet::Packet;
use std::io;
use std::net::Ipv4Addr;
use std::sync::Arc;
#[cfg(any(
target_os = "windows",
all(target_os = "linux", not(target_env = "ohos")),
target_os = "freebsd",
target_os = "macos",
targe... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/examples/read_interruptible.rs | examples/read_interruptible.rs | #[allow(unused_imports)]
use std::net::Ipv4Addr;
use std::sync::mpsc::Receiver;
#[allow(unused_imports)]
use std::sync::Arc;
#[allow(unused_imports)]
#[cfg(any(
target_os = "windows",
all(target_os = "linux", not(target_env = "ohos")),
target_os = "freebsd",
target_os = "openbsd",
target_os = "netb... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/examples/ping_offload.rs | examples/ping_offload.rs | #[allow(unused_imports)]
use bytes::BytesMut;
#[allow(unused_imports)]
use std::net::Ipv4Addr;
#[allow(unused_imports)]
use std::sync::Arc;
#[allow(unused_imports)]
#[cfg(all(target_os = "linux", not(target_env = "ohos")))]
use tun_rs::{AsyncDevice, DeviceBuilder, SyncDevice};
#[allow(unused_imports)]
#[cfg(all(target_... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/examples/async_ping.rs | examples/async_ping.rs | #[allow(unused_imports)]
use std::net::Ipv4Addr;
#[allow(unused_imports)]
use std::sync::Arc;
#[allow(unused_imports)]
#[cfg(any(
target_os = "windows",
all(target_os = "linux", not(target_env = "ohos")),
target_os = "macos",
target_os = "freebsd",
target_os = "openbsd",
target_os = "netbsd",
))... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/examples/read.rs | examples/read.rs | #[allow(unused_imports)]
use std::net::Ipv4Addr;
use std::sync::mpsc::Receiver;
#[allow(unused_imports)]
use std::sync::Arc;
#[allow(unused_imports)]
#[cfg(any(
target_os = "windows",
all(target_os = "linux", not(target_env = "ohos")),
target_os = "freebsd",
target_os = "macos",
target_os = "openbs... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/examples/async_ping_framed.rs | examples/async_ping_framed.rs | #[allow(unused_imports)]
use bytes::BytesMut;
#[allow(unused_imports)]
use futures::{SinkExt, StreamExt};
#[allow(unused_imports)]
use std::net::Ipv4Addr;
#[allow(unused_imports)]
use std::sync::Arc;
use tun_rs::async_framed::{BytesCodec, DeviceFramed};
#[cfg(any(
target_os = "windows",
all(target_os = "linux",... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/examples/read_timeout.rs | examples/read_timeout.rs | #[allow(unused_imports)]
use std::net::Ipv4Addr;
use std::sync::mpsc::Receiver;
#[allow(unused_imports)]
use std::sync::Arc;
use std::time::Duration;
#[allow(unused_imports)]
#[cfg(any(
target_os = "windows",
all(target_os = "linux", not(target_env = "ohos")),
target_os = "freebsd",
target_os = "openbsd... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
tun-rs/tun-rs | https://github.com/tun-rs/tun-rs/blob/c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7/examples/protocol_handle/mod.rs | examples/protocol_handle/mod.rs | #![allow(unused)]
use pnet_packet::arp::{ArpOperations, MutableArpPacket};
use pnet_packet::ethernet::{EthernetPacket, MutableEthernetPacket};
use pnet_packet::icmp::IcmpPacket;
use pnet_packet::icmp::IcmpTypes;
use pnet_packet::icmp::MutableIcmpPacket;
use pnet_packet::icmpv6::Icmpv6Packet;
use pnet_packet::icmpv6::I... | rust | Apache-2.0 | c8e1cd8eb96adf915f0ae95e7c502e0f9ffd91a7 | 2026-01-04T20:19:01.665942Z | false |
JoshMcguigan/shell_completion | https://github.com/JoshMcguigan/shell_completion/blob/7a07d42bf616e118c9cd692c0c3b63c05350d2e2/shell_completion/src/lib.rs | shell_completion/src/lib.rs | mod bash;
mod split;
pub use bash::BashCompletionInput;
pub trait CompletionInput : Sized {
fn args(&self) -> Vec<&str>;
fn arg_index(&self) -> usize;
fn char_index(&self) -> usize;
// Returns the current word under the users cursor
// Does not include any characters after the cursor
fn curre... | rust | Apache-2.0 | 7a07d42bf616e118c9cd692c0c3b63c05350d2e2 | 2026-01-04T20:19:09.999923Z | false |
JoshMcguigan/shell_completion | https://github.com/JoshMcguigan/shell_completion/blob/7a07d42bf616e118c9cd692c0c3b63c05350d2e2/shell_completion/src/bash.rs | shell_completion/src/bash.rs | use std::env;
use crate::CompletionInput;
use crate::split::{Split, SplitError};
/// BashCompletionInput is a struct which contains input data passed from the shell into a
/// completion script. Data within this struct should be used by a completion script to determine
/// appropriate completion options.
pub struct B... | rust | Apache-2.0 | 7a07d42bf616e118c9cd692c0c3b63c05350d2e2 | 2026-01-04T20:19:09.999923Z | false |
JoshMcguigan/shell_completion | https://github.com/JoshMcguigan/shell_completion/blob/7a07d42bf616e118c9cd692c0c3b63c05350d2e2/shell_completion/src/split.rs | shell_completion/src/split.rs | /// Unix shell word splitter
/// Derived from
/// https://github.com/AaronErhardt/shell-words/blob/1f0def71072a2be7b1105ee46b989bbb92762372/src/lib.rs#L46-L231
/// https://github.com/tmiasko/shell-words/blob/045e4dccd2478ccc8bfa91bd0fe449dfe5473496/src/lib.rs#L47-L229
use std::{fmt, mem};
/// An error returned when sh... | rust | Apache-2.0 | 7a07d42bf616e118c9cd692c0c3b63c05350d2e2 | 2026-01-04T20:19:09.999923Z | false |
JoshMcguigan/shell_completion | https://github.com/JoshMcguigan/shell_completion/blob/7a07d42bf616e118c9cd692c0c3b63c05350d2e2/cargo_completion/src/main.rs | cargo_completion/src/main.rs | use shell_completion::{BashCompletionInput, CompletionInput, CompletionSet};
fn main() {
let input = BashCompletionInput::from_env()
.expect("Missing expected environment variables");
complete(input).suggest();
}
fn complete(input: impl CompletionInput) -> Vec<String> {
match input.arg_index() {
... | rust | Apache-2.0 | 7a07d42bf616e118c9cd692c0c3b63c05350d2e2 | 2026-01-04T20:19:09.999923Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/config.rs | src/config.rs | use crate::{
audio::{Endianness, SampleFormat},
constants::{
COMPARATOR_DEFAULT_BAND_SIZE, DETECTOR_DEFAULT_AVG_THRESHOLD, DETECTOR_DEFAULT_MIN_SCORES,
DETECTOR_DEFAULT_REFERENCE, DETECTOR_DEFAULT_THRESHOLD, DETECTOR_INTERNAL_SAMPLE_RATE,
},
};
/// Wav format representation
#[cfg_attr(featur... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/lib.rs | src/lib.rs | mod audio;
mod config;
mod constants;
mod detector;
mod mfcc;
mod wakewords;
#[cfg(feature = "audio")]
pub use audio::{AudioEncoder, BandPassFilter, GainNormalizerFilter};
pub use audio::{Endianness, Sample, SampleFormat};
pub use config::{
AudioFmt, BandPassConfig, DetectorConfig, FiltersConfig, GainNormalizationC... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/detector.rs | src/detector.rs | use std::collections::HashMap;
use crate::{
audio::{AudioEncoder, BandPassFilter, GainNormalizerFilter},
constants::{
DETECTOR_INTERNAL_SAMPLE_RATE, MFCCS_EXTRACTOR_FRAME_LENGTH_MS,
MFCCS_EXTRACTOR_FRAME_SHIFT_MS, MFCCS_EXTRACTOR_PRE_EMPHASIS,
},
mfcc::{MfccExtractor, VadDetector},
... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/constants.rs | src/constants.rs | pub const DETECTOR_INTERNAL_SAMPLE_RATE: usize = 16000;
pub const MFCCS_EXTRACTOR_FRAME_LENGTH_MS: usize = 30;
pub(crate) const COMPARATOR_DEFAULT_BAND_SIZE: u16 = 5;
pub(crate) const DETECTOR_DEFAULT_AVG_THRESHOLD: f32 = 0.2;
pub(crate) const DETECTOR_DEFAULT_THRESHOLD: f32 = 0.5;
pub(crate) const DETECTOR_DEFAULT_MIN... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/wakewords/wakeword_file.rs | src/wakewords/wakeword_file.rs | use std::{fs::File, io::BufReader};
use ciborium::{de, ser};
use serde::{de::DeserializeOwned, Serialize};
use crate::ScoreMode;
use super::WakewordDetector;
pub trait WakewordSave: Serialize {
fn save_to_file(&self, path: &str) -> Result<(), String> {
let mut file = match File::create(path) {
... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/wakewords/wakeword_model.rs | src/wakewords/wakeword_model.rs | use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use crate::ScoreMode;
use super::nn::{WakewordModelTrain, WakewordNN};
use super::{WakewordDetector, WakewordFile, WakewordLoad, WakewordSave};
#[derive(Serialize, Deserialize)]
pub struct WakewordModel {
pub labels: Vec<String>,
pub train_... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/wakewords/wakeword_v2.rs | src/wakewords/wakeword_v2.rs | use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use crate::{WakewordLoad, WakewordRef};
/// Deprecated wakeword representation from v2
#[derive(Serialize, Deserialize)]
pub struct WakewordV2 {
pub name: String,
pub avg_features: Option<Vec<Vec<f32>>>,
pub samples_features: HashMap<Stri... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/wakewords/wakeword_detector.rs | src/wakewords/wakeword_detector.rs | use crate::{RustpotterDetection, ScoreMode};
pub(crate) trait WakewordDetector: Send {
fn get_mfcc_frame_size(&self) -> usize;
fn get_mfcc_size(&self) -> u16;
fn run_detection(
&self,
mfcc_frame: Vec<Vec<f32>>,
avg_threshold: f32,
threshold: f32,
) -> Option<RustpotterDe... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/wakewords/mod.rs | src/wakewords/mod.rs | mod comp;
mod nn;
mod wakeword_detector;
mod wakeword_file;
mod wakeword_model;
mod wakeword_ref;
mod wakeword_v2;
pub use comp::{WakewordRefBuildFromBuffers, WakewordRefBuildFromFiles};
pub use nn::{WakewordModelTrain, WakewordModelTrainOptions};
pub(crate) use wakeword_detector::WakewordDetector;
pub(crate) use wake... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/wakewords/wakeword_ref.rs | src/wakewords/wakeword_ref.rs | use super::{comp::WakewordComparator, WakewordDetector, WakewordFile};
use crate::{
mfcc::MfccComparator,
wakewords::{WakewordLoad, WakewordSave},
ScoreMode, WakewordRefBuildFromBuffers, WakewordRefBuildFromFiles,
};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
/// Wakeword represent... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/wakewords/comp/wakeword_ref_build.rs | src/wakewords/comp/wakeword_ref_build.rs | use std::{cmp::Ordering, collections::HashMap, fs::File, io::BufReader, path::Path};
use crate::{
mfcc::{MfccAverager, MfccWavFileExtractor},
WakewordRef,
};
pub trait WakewordRefBuildFromBuffers {
fn new_from_sample_buffers(
name: String,
threshold: Option<f32>,
avg_threshold: Opt... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/wakewords/comp/wakeword_comp.rs | src/wakewords/comp/wakeword_comp.rs | use std::collections::HashMap;
use crate::{
mfcc::{MfccComparator, MfccNormalizer},
wakewords::WakewordDetector,
RustpotterDetection, ScoreMode, WakewordRef,
};
pub(crate) struct WakewordComparator {
name: String,
avg_features: Option<Vec<Vec<f32>>>,
samples_features: HashMap<String, Vec<Vec<f... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/wakewords/comp/mod.rs | src/wakewords/comp/mod.rs | mod wakeword_comp;
mod wakeword_ref_build;
pub(crate) use wakeword_comp::WakewordComparator;
pub use wakeword_ref_build::{WakewordRefBuildFromBuffers, WakewordRefBuildFromFiles};
| rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/wakewords/nn/wakeword_nn.rs | src/wakewords/nn/wakeword_nn.rs | use crate::{
constants::{MFCCS_EXTRACTOR_OUT_SHIFTS, NN_NONE_LABEL},
mfcc::MfccNormalizer,
wakewords::WakewordDetector,
wakewords::{ModelWeights, TensorData},
ModelType, RustpotterDetection, ScoreMode, WakewordModel,
};
use candle_core::{DType, Device, Tensor, Var};
use candle_nn::{Linear, Module, V... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/wakewords/nn/wakeword_model_train.rs | src/wakewords/nn/wakeword_model_train.rs | use super::wakeword_nn::{
flat_features, get_tensors_data, init_model_impl, LargeModel, MediumModel, ModelImpl, TinyModel,
};
use crate::{
constants::NN_NONE_LABEL,
mfcc::MfccWavFileExtractor,
wakewords::{nn::wakeword_nn::SmallModel, ModelWeights},
ModelType, WakewordModel,
};
use candle_core::{DTyp... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/wakewords/nn/mod.rs | src/wakewords/nn/mod.rs | mod wakeword_model_train;
mod wakeword_nn;
pub use wakeword_model_train::{WakewordModelTrain, WakewordModelTrainOptions};
pub(crate) use wakeword_nn::WakewordNN;
| rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/audio/encoder.rs | src/audio/encoder.rs | use rubato::{FftFixedInOut, Resampler};
use crate::{config::AudioFmt, Endianness, Sample, SampleFormat};
/// Encode and convert audio to the supported format.
pub struct AudioEncoder {
resampler: Option<FftFixedInOut<f32>>,
resampler_input_buffer: Option<Vec<Vec<f32>>>,
resampler_out_buffer: Option<Vec<Ve... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/audio/audio_types.rs | src/audio/audio_types.rs | /// Indicates the sample format type and size
#[cfg_attr(feature = "debug", derive(Debug))]
#[derive(Clone)]
pub enum SampleFormat {
I8,
I16,
I32,
F32,
}
impl SampleFormat {
pub fn get_bits_per_sample(&self) -> u16 {
match self {
SampleFormat::I8 => 8,
SampleFormat::I... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/audio/gain_normalizer_filter.rs | src/audio/gain_normalizer_filter.rs | use crate::GainNormalizationConfig;
pub struct GainNormalizerFilter {
window_size: usize,
fixed_rms_level: bool,
min_gain: f32,
max_gain: f32,
// state
rms_level_ref: f32,
rms_level_sqrt: f32,
rms_level_window: Vec<f32>,
}
impl GainNormalizerFilter {
pub fn filter(&mut self, signal:... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/audio/band_pass_filter.rs | src/audio/band_pass_filter.rs | use std::f32::consts::PI;
use crate::{constants::DETECTOR_INTERNAL_SAMPLE_RATE, BandPassConfig};
pub struct BandPassFilter {
// options
a0: f32,
a1: f32,
a2: f32,
b1: f32,
b2: f32,
// state
x1: f32,
x2: f32,
y1: f32,
y2: f32,
}
impl BandPassFilter {
pub fn filter(&mut s... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/audio/mod.rs | src/audio/mod.rs | mod audio_types;
mod band_pass_filter;
mod encoder;
mod gain_normalizer_filter;
pub use audio_types::{Endianness, Sample, SampleFormat};
pub use band_pass_filter::BandPassFilter;
pub use encoder::AudioEncoder;
pub use gain_normalizer_filter::GainNormalizerFilter;
| rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/mfcc/extractor.rs | src/mfcc/extractor.rs | use std::f32::consts::PI;
use rustfft::{num_complex::Complex32, FftPlanner};
pub struct MfccExtractor {
num_coefficients: usize,
pre_emphasis_coefficient: f32,
samples_per_frame: usize,
samples_per_shift: usize,
magnitude_spectrum_size: usize,
sample_rate: usize,
// state
filter_bank: ... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/mfcc/normalizer.rs | src/mfcc/normalizer.rs | pub struct MfccNormalizer {}
impl MfccNormalizer {
pub fn normalize(frames: Vec<Vec<f32>>) -> Vec<Vec<f32>> {
let num_frames = frames.len();
if num_frames == 0 {
return Vec::new();
}
let num_mfccs = frames[0].len();
let mut sum = Vec::with_capacity(num_mfccs);
... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/mfcc/comparator.rs | src/mfcc/comparator.rs | use super::Dtw;
use std::cmp;
pub struct MfccComparator {
score_ref: f32,
band_size: u16,
}
impl MfccComparator {
pub fn new(score_ref: f32, band_size: u16) -> Self {
MfccComparator {
score_ref,
band_size,
}
}
pub fn calculate_distance(ax: &[f32], bx: &[f32])... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/mfcc/averager.rs | src/mfcc/averager.rs | use super::{dtw::Dtw, MfccComparator};
pub struct MfccAverager {}
impl MfccAverager {
pub fn average(mut other_mfccs: Vec<Vec<Vec<f32>>>) -> Option<Vec<Vec<f32>>> {
let mut origin = other_mfccs.drain(0..1).next().unwrap();
for frames in other_mfccs.iter() {
let mut dtw = Dtw::new(MfccCo... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/mfcc/dtw.rs | src/mfcc/dtw.rs | use std::cmp;
pub struct Dtw<T: Copy> {
state_m: usize,
state_n: usize,
distance_fn: fn(T, T) -> f32,
state_similarity: Option<f32>,
distance_cost_matrix: Option<Vec<Vec<f32>>>,
}
impl<T: Copy> Dtw<T> {
pub fn compute_optimal_path(&mut self, first_sequence: &[T], second_sequence: &[T]) -> f32 {... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/mfcc/wav_file_extractor.rs | src/mfcc/wav_file_extractor.rs | use std::io::BufReader;
use hound::{WavReader, WavSpec};
use crate::{
audio::{AudioEncoder, GainNormalizerFilter},
constants::{
DETECTOR_INTERNAL_SAMPLE_RATE, MFCCS_EXTRACTOR_FRAME_LENGTH_MS,
MFCCS_EXTRACTOR_FRAME_SHIFT_MS, MFCCS_EXTRACTOR_PRE_EMPHASIS,
},
AudioFmt, Endianness, Sample,... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/mfcc/mod.rs | src/mfcc/mod.rs | mod averager;
mod comparator;
mod dtw;
mod extractor;
mod normalizer;
mod vad;
mod wav_file_extractor;
pub(crate) use averager::MfccAverager;
pub(crate) use comparator::MfccComparator;
use dtw::Dtw;
pub(crate) use extractor::MfccExtractor;
pub(crate) use normalizer::MfccNormalizer;
pub(crate) use vad::VadDetector;
pub(... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/src/mfcc/vad.rs | src/mfcc/vad.rs | use crate::config::VADMode;
pub struct VadDetector {
mode: VADMode,
// state
index: usize,
window: Vec<f32>,
voice_countdown: usize,
}
impl VadDetector {
pub fn is_voice(&mut self, mfcc: &[f32]) -> bool {
let value: f32 = mfcc.iter().map(|v| v.abs()).sum::<f32>() / mfcc.len() as f32;
... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/tests/detector.rs | tests/detector.rs | use std::{
fs::File,
io::{BufReader, Read},
};
use rustpotter::{Rustpotter, RustpotterConfig, SampleFormat, ScoreMode, VADMode};
#[test]
fn it_can_detect_wakewords_with_v2_file() {
let mut config = RustpotterConfig::default();
config.detector.avg_threshold = 0.2;
config.detector.threshold = 0.5;
... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
GiviMAD/rustpotter | https://github.com/GiviMAD/rustpotter/blob/46bbc73223afe5fc7b90f30455046432fc3c9432/tests/wakeword.rs | tests/wakeword.rs | use rustpotter::{
ModelType, WakewordLoad, WakewordModel, WakewordModelTrain, WakewordModelTrainOptions,
WakewordRef, WakewordRefBuildFromFiles, WakewordSave,
};
#[test]
fn it_creates_a_new_wakeword_from_samples() {
let dir = env!("CARGO_MANIFEST_DIR");
let samples = vec![
dir.to_owned() + "/te... | rust | Apache-2.0 | 46bbc73223afe5fc7b90f30455046432fc3c9432 | 2026-01-04T20:17:53.884437Z | false |
achanda/ipnetwork | https://github.com/achanda/ipnetwork/blob/f01575cbf2fc596c0a1761c122aa92525cbb7974/src/lib.rs | src/lib.rs | //! The `ipnetwork` crate provides a set of APIs to work with IP CIDRs in
//! Rust.
#![crate_type = "lib"]
#![deny(
missing_debug_implementations,
unsafe_code,
unused_extern_crates,
unused_import_braces
)]
use std::{
convert::TryFrom,
fmt,
net::{IpAddr, Ipv4Addr, Ipv6Addr},
str::FromStr... | rust | Apache-2.0 | f01575cbf2fc596c0a1761c122aa92525cbb7974 | 2026-01-04T20:19:08.816812Z | false |
achanda/ipnetwork | https://github.com/achanda/ipnetwork/blob/f01575cbf2fc596c0a1761c122aa92525cbb7974/src/parse.rs | src/parse.rs | use crate::error::IpNetworkError;
pub fn cidr_parts(cidr: &str) -> Result<(&str, Option<&str>), IpNetworkError> {
// Try to find a single slash
if let Some(sep) = cidr.find('/') {
let (ip, prefix) = cidr.split_at(sep);
// Error if cidr has multiple slashes
if prefix[1..].find('/').is_so... | rust | Apache-2.0 | f01575cbf2fc596c0a1761c122aa92525cbb7974 | 2026-01-04T20:19:08.816812Z | false |
achanda/ipnetwork | https://github.com/achanda/ipnetwork/blob/f01575cbf2fc596c0a1761c122aa92525cbb7974/src/ipv4.rs | src/ipv4.rs | use crate::error::IpNetworkError;
use crate::parse::{cidr_parts, parse_prefix};
use std::{convert::TryFrom, fmt, net::Ipv4Addr, str::FromStr};
const IPV4_BITS: u8 = 32;
/// Represents a network range where the IP addresses are of v4
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub struct Ipv4Ne... | rust | Apache-2.0 | f01575cbf2fc596c0a1761c122aa92525cbb7974 | 2026-01-04T20:19:08.816812Z | false |
achanda/ipnetwork | https://github.com/achanda/ipnetwork/blob/f01575cbf2fc596c0a1761c122aa92525cbb7974/src/error.rs | src/error.rs | use std::{error::Error, fmt, net::AddrParseError};
use crate::error::IpNetworkError::*;
/// Represents a bunch of errors that can occur while working with a `IpNetwork`
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum IpNetworkError {
InvalidAddr(String),
InvalidPrefix,
InvalidCidrFormat(... | rust | Apache-2.0 | f01575cbf2fc596c0a1761c122aa92525cbb7974 | 2026-01-04T20:19:08.816812Z | false |
achanda/ipnetwork | https://github.com/achanda/ipnetwork/blob/f01575cbf2fc596c0a1761c122aa92525cbb7974/src/ipv6.rs | src/ipv6.rs | use crate::error::IpNetworkError;
use crate::parse::{cidr_parts, parse_prefix};
use std::{convert::TryFrom, fmt, net::Ipv6Addr, str::FromStr};
const IPV6_BITS: u8 = 128;
const IPV6_SEGMENT_BITS: u8 = 16;
/// Represents a network range where the IP addresses are of v6
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, ... | rust | Apache-2.0 | f01575cbf2fc596c0a1761c122aa92525cbb7974 | 2026-01-04T20:19:08.816812Z | false |
achanda/ipnetwork | https://github.com/achanda/ipnetwork/blob/f01575cbf2fc596c0a1761c122aa92525cbb7974/src/size.rs | src/size.rs | use std::{
cmp::Ordering,
fmt::Display,
hash::{Hash, Hasher},
};
use crate::error::NetworkSizeError;
use NetworkSize::*;
/// Represents a generic network size.
///
/// IPv4 network sizes are represented as `u32` values, while IPv6 network sizes are represented as `u128` values.
///
/// # Comparisons
///
/... | rust | Apache-2.0 | f01575cbf2fc596c0a1761c122aa92525cbb7974 | 2026-01-04T20:19:08.816812Z | false |
achanda/ipnetwork | https://github.com/achanda/ipnetwork/blob/f01575cbf2fc596c0a1761c122aa92525cbb7974/tests/test_json.rs | tests/test_json.rs | #![cfg(feature = "serde")]
#[cfg(test)]
mod tests {
use ipnetwork::{IpNetwork, Ipv4Network, Ipv6Network};
use serde::{Deserialize, Serialize};
use std::net::{Ipv4Addr, Ipv6Addr};
#[test]
fn test_ipv4_json() {
let json_string = r#"{"ipnetwork":"127.1.0.0/24"}"#;
#[derive(Serialize,... | rust | Apache-2.0 | f01575cbf2fc596c0a1761c122aa92525cbb7974 | 2026-01-04T20:19:08.816812Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.