Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: Add an example #6

Merged
merged 9 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,9 @@ jobs:
# no memory and leak sanitizer support yet
SANITIZERS="address thread"
fi

for sanitizer in $SANITIZERS; do
echo "Running tests with $sanitizer sanitizer..."
RUSTFLAGS="-Z sanitizer=$sanitizer" cargo +nightly test -Z build-std --target "$TARGET"
RUSTFLAGS="-Z sanitizer=$sanitizer" RUSTDOCFLAGS="-Z sanitizer=$sanitizer" cargo +nightly test -Z build-std --target "$TARGET"
done

- name: Check formatting
Expand Down
13 changes: 13 additions & 0 deletions .rustfmt.toml
larseggert marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Keep in sync with `Cargo.toml` `edition`.
#
# `rustfmt` envoked not through `cargo fmt` but directly does not pick up Rust
# edition in `Cargo.toml`. Thus duplicate here.
edition = "2021"

comment_width=100
wrap_comments=true

imports_granularity="Crate"
group_imports="StdExternalCrate"

format_code_in_doc_comments=true
17 changes: 16 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,22 @@ fn default_result<T>() -> Result<T, Error> {
))
}

/// Return the MTU of the interface that is used to reach the given remote socket address.
/// Return the maximum transmission unit (MTU) of the local network interface towards the
/// destination [`SocketAddr`] given in `remote`.
///
/// The returned MTU may exceed the maximum IP packet size of 65,535 bytes on some
/// platforms for some remote destinations. (For example, loopback destinations on
/// Windows.)
///
/// # Examples
///
/// ```
/// # use std::net::ToSocketAddrs;
/// # use mtu::get_interface_mtu;
larseggert marked this conversation as resolved.
Show resolved Hide resolved
/// let saddr = "127.0.0.1:443".parse().unwrap();
/// let mtu = get_interface_mtu(&saddr).unwrap();
/// println!("MTU towards {:?} is {}", saddr, mtu);
/// ```
///
/// # Errors
///
Expand Down
Loading