WireGuardPeer

Struct WireGuardPeer 

Source
pub struct WireGuardPeer { /* private fields */ }
Available on crate feature v1_16 only.
Expand description

The settings of one WireGuard peer.

GLib type: Shared boxed type with reference counted clone semantics.

Implementations§

Source§

impl WireGuardPeer

Source

pub fn as_ptr(&self) -> *mut NMWireGuardPeer

Return the inner pointer to the underlying C value.

Source

pub unsafe fn from_glib_ptr_borrow(ptr: &*mut NMWireGuardPeer) -> &Self

Borrows the underlying C value.

Source§

impl WireGuardPeer

Source

pub fn new() -> WireGuardPeer

§Returns

a new, default, unsealed #NMWireGuardPeer instance.

Source

pub fn append_allowed_ip(&self, allowed_ip: &str, accept_invalid: bool) -> bool

Appends @allowed_ip setting to the list. This does not check for duplicates and always appends @allowed_ip to the end of the list. If @allowed_ip is valid, it will be normalized and a modified for might be appended. If @allowed_ip is invalid, it will still be appended, but later verification will fail.

It is a bug trying to modify a sealed #NMWireGuardPeer instance.

§allowed_ip

the allowed-ip entry to set.

§accept_invalid

if true, also invalid @allowed_ip value will be appended. Otherwise, the function does nothing in face of invalid values and returns false.

§Returns

true if the value is a valid allowed-ips value, false otherwise. Depending on @accept_invalid, also invalid values are added.

Source

pub fn clear_allowed_ips(&self)

Removes all allowed-ip entries.

It is a bug trying to modify a sealed #NMWireGuardPeer instance.

Source

pub fn cmp( &self, b: Option<&WireGuardPeer>, compare_flags: SettingCompareFlags, ) -> i32

§b

the other #NMWireGuardPeer to compare.

§compare_flags

#NMSettingCompareFlags to affect the comparison.

§Returns

zero of the two instances are equivalent or a non-zero integer otherwise. This defines a total ordering over the peers. Whether a peer is sealed or not, does not affect the comparison.

Source

pub fn allowed_ip(&self, idx: u32, out_is_valid: bool) -> Option<GString>

§idx

the index from zero to (allowed-ips-len - 1) to retrieve.

§out_is_valid

true if the returned value is a valid allowed-ip setting. This parameter is wrongly not marked as (out) argument, it is thus not accessible via introspection. This cannot be fixed without breaking API for introspection users.

§Returns

the allowed-ip setting at index @idx. If @idx is out of range, None will be returned.

Source

pub fn allowed_ips_len(&self) -> u32

§Returns

the number of allowed-ips entries.

Source

pub fn endpoint(&self) -> GString

§Returns

the endpoint or None if none was set.

Source

pub fn persistent_keepalive(&self) -> u16

§Returns

get the persistent-keepalive setting in seconds. Set to zero to disable keep-alive.

Source

pub fn preshared_key(&self) -> GString

§Returns

the preshared key or None if unset.

Source

pub fn preshared_key_flags(&self) -> SettingSecretFlags

§Returns

get the secret flags for the preshared-key.

Source

pub fn public_key(&self) -> GString

§Returns

the public key or None if unset.

Source

pub fn is_sealed(&self) -> bool

§Returns

whether @self is sealed or not.

Source

pub fn is_valid( &self, check_non_secrets: bool, check_secrets: bool, ) -> Result<(), Error>

§check_non_secrets

if true, secret properties are validated. Otherwise, they are ignored for this purpose.

§check_secrets

if true, non-secret properties are validated. Otherwise, they are ignored for this purpose.

§Returns

true if the peer is valid or fails with an error reason.

Source

pub fn new_clone(&self, with_secrets: bool) -> WireGuardPeer

§with_secrets

if true, the preshared-key secrets are copied as well. Otherwise, they will be removed.

§Returns

a clone of @self. This instance is always unsealed.

Source

pub fn remove_allowed_ip(&self, idx: u32) -> bool

Removes the allowed-ip at the given @idx. This shifts all following entries one index down.

It is a bug trying to modify a sealed #NMWireGuardPeer instance.

§idx

the index from zero to (allowed-ips-len - 1) to retrieve. If the index is out of range, false is returned and nothing is done.

§Returns

true if @idx was valid and the allowed-ip was removed. false otherwise, and the peer will not be changed.

Source

pub fn seal(&self)

Seal the #NMWireGuardPeer instance. Afterwards, it is a bug to call all functions that modify the instance (except ref/unref). A sealed instance cannot be unsealed again, but you can create an unsealed copy with nm_wireguard_peer_new_clone().

Source

pub fn set_endpoint(&self, endpoint: &str, allow_invalid: bool) -> bool

Sets or clears the endpoint of @self.

It is a bug trying to modify a sealed #NMWireGuardPeer instance.

§endpoint

the socket address endpoint to set or None.

§allow_invalid

if true, also invalid values are set. If false, the function does nothing for invalid @endpoint arguments.

§Returns

true if the endpoint is None or valid. For an invalid @endpoint argument, false is returned. Depending on @allow_invalid, the instance will be modified.

Source

pub fn set_persistent_keepalive(&self, persistent_keepalive: u16)

It is a bug trying to modify a sealed #NMWireGuardPeer instance.

§persistent_keepalive

the keep-alive value to set.

Source

pub fn set_preshared_key( &self, preshared_key: Option<&str>, accept_invalid: bool, ) -> bool

Reset the preshared key. Note that if the preshared key is valid, it will be normalized (which may or may not modify the set value).

Note that the preshared-key is a secret and consequently has corresponding preshared-key-flags property. This is so that secrets can be optional and requested on demand from a secret-agent. Also, an invalid preshared-key may optionally cause nm_wireguard_peer_is_valid() to fail or it may be accepted.

It is a bug trying to modify a sealed #NMWireGuardPeer instance.

§preshared_key

the new preshared key or None to clear the preshared key.

§accept_invalid

whether to allow setting the key to an invalid value. If false, @self is unchanged if the key is invalid and if false is returned.

§Returns

true if the preshared-key is valid, otherwise false. None is considered a valid value. If the key is invalid, it depends on @accept_invalid whether the previous value was reset.

Source

pub fn set_preshared_key_flags(&self, preshared_key_flags: SettingSecretFlags)

It is a bug trying to modify a sealed #NMWireGuardPeer instance.

§preshared_key_flags

the secret flags to set.

Source

pub fn set_public_key( &self, public_key: Option<&str>, accept_invalid: bool, ) -> bool

Reset the public key. Note that if the public key is valid, it will be normalized (which may or may not modify the set value).

It is a bug trying to modify a sealed #NMWireGuardPeer instance.

§public_key

the new public key or None to clear the public key.

§accept_invalid

if true and @public_key is not None and invalid, then do not modify the instance.

§Returns

true if the key was valid or None. Returns false for invalid keys. Depending on @accept_invalid will an invalid key be set or not.

Trait Implementations§

Source§

impl Clone for WireGuardPeer

Source§

fn clone(&self) -> Self

Makes a clone of this shared reference.

This increments the strong reference count of the reference. Dropping the reference will decrement it again.

1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WireGuardPeer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for WireGuardPeer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<WireGuardPeer> for Value

Source§

fn from(s: WireGuardPeer) -> Self

Converts to this type from the input type.
Source§

impl HasParamSpec for WireGuardPeer

Source§

type ParamSpec = ParamSpecBoxed

Source§

type SetValue = WireGuardPeer

Preferred value to be used as setter for the associated ParamSpec.
Source§

type BuilderFn = fn(&str) -> ParamSpecBoxedBuilder<'_, WireGuardPeer>

Source§

fn param_spec_builder() -> Self::BuilderFn

Source§

impl Hash for WireGuardPeer

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for WireGuardPeer

Source§

fn cmp(&self, other: &WireGuardPeer) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for WireGuardPeer

Source§

fn eq(&self, other: &WireGuardPeer) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for WireGuardPeer

Source§

fn partial_cmp(&self, other: &WireGuardPeer) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StaticType for WireGuardPeer

Source§

fn static_type() -> Type

Returns the type identifier of Self.
Source§

impl Eq for WireGuardPeer

Source§

impl StructuralPartialEq for WireGuardPeer

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for T

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoClosureReturnValue for T
where T: Into<Value>,

Source§

impl<T> Property for T
where T: HasParamSpec,

Source§

type Value = T

Source§

impl<T> PropertyGet for T
where T: HasParamSpec,

Source§

type Value = T

Source§

fn get<R, F>(&self, f: F) -> R
where F: Fn(&<T as PropertyGet>::Value) -> R,

Source§

impl<T> StaticTypeExt for T
where T: StaticType,

Source§

fn ensure_type()

Ensures that the type has been registered with the type system.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> TransparentType for T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T> TryFromClosureReturnValue for T
where T: for<'a> FromValue<'a> + StaticType + 'static,

Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<'a, T, C, E> FromValueOptional<'a> for T
where T: FromValue<'a, Checker = C>, C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError<E>>, E: Error + Send + 'static,