1use crate::{ffi,Setting};
7#[cfg(feature = "v1_6")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
9use crate::{SettingMacsecMode,SettingMacsecValidation,SettingSecretFlags};
10#[cfg(feature = "v1_46")]
11#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
12use crate::{SettingMacsecOffload};
13use glib::{prelude::*};
14#[cfg(feature = "v1_6")]
15#[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
16use glib::{signal::{connect_raw, SignalHandlerId},translate::*};
17#[cfg(feature = "v1_6")]
18#[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
19use std::{boxed::Box as Box_};
20
21glib::wrapper! {
22 #[doc(alias = "NMSettingMacsec")]
119 pub struct SettingMacsec(Object<ffi::NMSettingMacsec, ffi::NMSettingMacsecClass>) @extends Setting;
120
121 match fn {
122 type_ => || ffi::nm_setting_macsec_get_type(),
123 }
124}
125
126impl SettingMacsec {
127 #[cfg(feature = "v1_6")]
133 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
134 #[doc(alias = "nm_setting_macsec_new")]
135 pub fn new() -> SettingMacsec {
136 assert_initialized_main_thread!();
137 unsafe {
138 Setting::from_glib_full(ffi::nm_setting_macsec_new()).unsafe_cast()
139 }
140 }
141
142 pub fn builder() -> SettingMacsecBuilder {
147 SettingMacsecBuilder::new()
148 }
149
150
151 #[cfg(feature = "v1_6")]
156 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
157 #[doc(alias = "nm_setting_macsec_get_encrypt")]
158 #[doc(alias = "get_encrypt")]
159 #[doc(alias = "encrypt")]
160 pub fn is_encrypt(&self) -> bool {
161 unsafe {
162 from_glib(ffi::nm_setting_macsec_get_encrypt(self.to_glib_none().0))
163 }
164 }
165
166 #[cfg(feature = "v1_6")]
171 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
172 #[doc(alias = "nm_setting_macsec_get_mka_cak")]
173 #[doc(alias = "get_mka_cak")]
174 #[doc(alias = "mka-cak")]
175 pub fn mka_cak(&self) -> glib::GString {
176 unsafe {
177 from_glib_none(ffi::nm_setting_macsec_get_mka_cak(self.to_glib_none().0))
178 }
179 }
180
181 #[cfg(feature = "v1_6")]
186 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
187 #[doc(alias = "nm_setting_macsec_get_mka_cak_flags")]
188 #[doc(alias = "get_mka_cak_flags")]
189 #[doc(alias = "mka-cak-flags")]
190 pub fn mka_cak_flags(&self) -> SettingSecretFlags {
191 unsafe {
192 from_glib(ffi::nm_setting_macsec_get_mka_cak_flags(self.to_glib_none().0))
193 }
194 }
195
196 #[cfg(feature = "v1_6")]
201 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
202 #[doc(alias = "nm_setting_macsec_get_mka_ckn")]
203 #[doc(alias = "get_mka_ckn")]
204 #[doc(alias = "mka-ckn")]
205 pub fn mka_ckn(&self) -> glib::GString {
206 unsafe {
207 from_glib_none(ffi::nm_setting_macsec_get_mka_ckn(self.to_glib_none().0))
208 }
209 }
210
211 #[cfg(feature = "v1_6")]
216 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
217 #[doc(alias = "nm_setting_macsec_get_mode")]
218 #[doc(alias = "get_mode")]
219 pub fn mode(&self) -> SettingMacsecMode {
220 unsafe {
221 from_glib(ffi::nm_setting_macsec_get_mode(self.to_glib_none().0))
222 }
223 }
224
225 #[cfg(feature = "v1_46")]
230 #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
231 #[doc(alias = "nm_setting_macsec_get_offload")]
232 #[doc(alias = "get_offload")]
233 pub fn offload(&self) -> SettingMacsecOffload {
234 unsafe {
235 from_glib(ffi::nm_setting_macsec_get_offload(self.to_glib_none().0))
236 }
237 }
238
239 #[cfg(feature = "v1_6")]
244 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
245 #[doc(alias = "nm_setting_macsec_get_parent")]
246 #[doc(alias = "get_parent")]
247 pub fn parent(&self) -> glib::GString {
248 unsafe {
249 from_glib_none(ffi::nm_setting_macsec_get_parent(self.to_glib_none().0))
250 }
251 }
252
253 #[cfg(feature = "v1_6")]
258 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
259 #[doc(alias = "nm_setting_macsec_get_port")]
260 #[doc(alias = "get_port")]
261 pub fn port(&self) -> i32 {
262 unsafe {
263 ffi::nm_setting_macsec_get_port(self.to_glib_none().0)
264 }
265 }
266
267 #[cfg(feature = "v1_12")]
272 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
273 #[doc(alias = "nm_setting_macsec_get_send_sci")]
274 #[doc(alias = "get_send_sci")]
275 #[doc(alias = "send-sci")]
276 pub fn is_send_sci(&self) -> bool {
277 unsafe {
278 from_glib(ffi::nm_setting_macsec_get_send_sci(self.to_glib_none().0))
279 }
280 }
281
282 #[cfg(feature = "v1_6")]
287 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
288 #[doc(alias = "nm_setting_macsec_get_validation")]
289 #[doc(alias = "get_validation")]
290 pub fn validation(&self) -> SettingMacsecValidation {
291 unsafe {
292 from_glib(ffi::nm_setting_macsec_get_validation(self.to_glib_none().0))
293 }
294 }
295
296 #[cfg(feature = "v1_6")]
298 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
299 pub fn set_encrypt(&self, encrypt: bool) {
300 ObjectExt::set_property(self,"encrypt", encrypt)
301 }
302
303 #[cfg(feature = "v1_6")]
306 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
307 #[doc(alias = "mka-cak")]
308 pub fn set_mka_cak(&self, mka_cak: Option<&str>) {
309 ObjectExt::set_property(self,"mka-cak", mka_cak)
310 }
311
312 #[cfg(feature = "v1_6")]
315 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
316 #[doc(alias = "mka-cak-flags")]
317 pub fn set_mka_cak_flags(&self, mka_cak_flags: SettingSecretFlags) {
318 ObjectExt::set_property(self,"mka-cak-flags", mka_cak_flags)
319 }
320
321 #[cfg(feature = "v1_6")]
325 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
326 #[doc(alias = "mka-ckn")]
327 pub fn set_mka_ckn(&self, mka_ckn: Option<&str>) {
328 ObjectExt::set_property(self,"mka-ckn", mka_ckn)
329 }
330
331 #[cfg(feature = "v1_6")]
334 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
335 pub fn set_mode(&self, mode: i32) {
336 ObjectExt::set_property(self,"mode", mode)
337 }
338
339 #[cfg(feature = "v1_46")]
351 #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
352 pub fn set_offload(&self, offload: i32) {
353 ObjectExt::set_property(self,"offload", offload)
354 }
355
356 #[cfg(feature = "v1_6")]
361 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
362 pub fn set_parent(&self, parent: Option<&str>) {
363 ObjectExt::set_property(self,"parent", parent)
364 }
365
366 #[cfg(feature = "v1_6")]
368 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
369 pub fn set_port(&self, port: i32) {
370 ObjectExt::set_property(self,"port", port)
371 }
372
373 #[cfg(feature = "v1_12")]
376 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
377 #[doc(alias = "send-sci")]
378 pub fn set_send_sci(&self, send_sci: bool) {
379 ObjectExt::set_property(self,"send-sci", send_sci)
380 }
381
382 #[cfg(feature = "v1_6")]
384 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
385 pub fn set_validation(&self, validation: i32) {
386 ObjectExt::set_property(self,"validation", validation)
387 }
388
389 #[cfg(feature = "v1_6")]
390 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
391 #[doc(alias = "encrypt")]
392 pub fn connect_encrypt_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
393 unsafe extern "C" fn notify_encrypt_trampoline<F: Fn(&SettingMacsec) + 'static>(this: *mut ffi::NMSettingMacsec, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
394 let f: &F = &*(f as *const F);
395 f(&from_glib_borrow(this))
396 }
397 unsafe {
398 let f: Box_<F> = Box_::new(f);
399 connect_raw(self.as_ptr() as *mut _, c"notify::encrypt".as_ptr() as *const _,
400 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_encrypt_trampoline::<F> as *const ())), Box_::into_raw(f))
401 }
402 }
403
404 #[cfg(feature = "v1_6")]
405 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
406 #[doc(alias = "mka-cak")]
407 pub fn connect_mka_cak_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
408 unsafe extern "C" fn notify_mka_cak_trampoline<F: Fn(&SettingMacsec) + 'static>(this: *mut ffi::NMSettingMacsec, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
409 let f: &F = &*(f as *const F);
410 f(&from_glib_borrow(this))
411 }
412 unsafe {
413 let f: Box_<F> = Box_::new(f);
414 connect_raw(self.as_ptr() as *mut _, c"notify::mka-cak".as_ptr() as *const _,
415 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_mka_cak_trampoline::<F> as *const ())), Box_::into_raw(f))
416 }
417 }
418
419 #[cfg(feature = "v1_6")]
420 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
421 #[doc(alias = "mka-cak-flags")]
422 pub fn connect_mka_cak_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
423 unsafe extern "C" fn notify_mka_cak_flags_trampoline<F: Fn(&SettingMacsec) + 'static>(this: *mut ffi::NMSettingMacsec, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
424 let f: &F = &*(f as *const F);
425 f(&from_glib_borrow(this))
426 }
427 unsafe {
428 let f: Box_<F> = Box_::new(f);
429 connect_raw(self.as_ptr() as *mut _, c"notify::mka-cak-flags".as_ptr() as *const _,
430 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_mka_cak_flags_trampoline::<F> as *const ())), Box_::into_raw(f))
431 }
432 }
433
434 #[cfg(feature = "v1_6")]
435 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
436 #[doc(alias = "mka-ckn")]
437 pub fn connect_mka_ckn_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
438 unsafe extern "C" fn notify_mka_ckn_trampoline<F: Fn(&SettingMacsec) + 'static>(this: *mut ffi::NMSettingMacsec, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
439 let f: &F = &*(f as *const F);
440 f(&from_glib_borrow(this))
441 }
442 unsafe {
443 let f: Box_<F> = Box_::new(f);
444 connect_raw(self.as_ptr() as *mut _, c"notify::mka-ckn".as_ptr() as *const _,
445 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_mka_ckn_trampoline::<F> as *const ())), Box_::into_raw(f))
446 }
447 }
448
449 #[cfg(feature = "v1_6")]
450 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
451 #[doc(alias = "mode")]
452 pub fn connect_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
453 unsafe extern "C" fn notify_mode_trampoline<F: Fn(&SettingMacsec) + 'static>(this: *mut ffi::NMSettingMacsec, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
454 let f: &F = &*(f as *const F);
455 f(&from_glib_borrow(this))
456 }
457 unsafe {
458 let f: Box_<F> = Box_::new(f);
459 connect_raw(self.as_ptr() as *mut _, c"notify::mode".as_ptr() as *const _,
460 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_mode_trampoline::<F> as *const ())), Box_::into_raw(f))
461 }
462 }
463
464 #[cfg(feature = "v1_46")]
465 #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
466 #[doc(alias = "offload")]
467 pub fn connect_offload_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
468 unsafe extern "C" fn notify_offload_trampoline<F: Fn(&SettingMacsec) + 'static>(this: *mut ffi::NMSettingMacsec, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
469 let f: &F = &*(f as *const F);
470 f(&from_glib_borrow(this))
471 }
472 unsafe {
473 let f: Box_<F> = Box_::new(f);
474 connect_raw(self.as_ptr() as *mut _, c"notify::offload".as_ptr() as *const _,
475 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_offload_trampoline::<F> as *const ())), Box_::into_raw(f))
476 }
477 }
478
479 #[cfg(feature = "v1_6")]
480 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
481 #[doc(alias = "parent")]
482 pub fn connect_parent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
483 unsafe extern "C" fn notify_parent_trampoline<F: Fn(&SettingMacsec) + 'static>(this: *mut ffi::NMSettingMacsec, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
484 let f: &F = &*(f as *const F);
485 f(&from_glib_borrow(this))
486 }
487 unsafe {
488 let f: Box_<F> = Box_::new(f);
489 connect_raw(self.as_ptr() as *mut _, c"notify::parent".as_ptr() as *const _,
490 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_parent_trampoline::<F> as *const ())), Box_::into_raw(f))
491 }
492 }
493
494 #[cfg(feature = "v1_6")]
495 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
496 #[doc(alias = "port")]
497 pub fn connect_port_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
498 unsafe extern "C" fn notify_port_trampoline<F: Fn(&SettingMacsec) + 'static>(this: *mut ffi::NMSettingMacsec, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
499 let f: &F = &*(f as *const F);
500 f(&from_glib_borrow(this))
501 }
502 unsafe {
503 let f: Box_<F> = Box_::new(f);
504 connect_raw(self.as_ptr() as *mut _, c"notify::port".as_ptr() as *const _,
505 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_port_trampoline::<F> as *const ())), Box_::into_raw(f))
506 }
507 }
508
509 #[cfg(feature = "v1_12")]
510 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
511 #[doc(alias = "send-sci")]
512 pub fn connect_send_sci_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
513 unsafe extern "C" fn notify_send_sci_trampoline<F: Fn(&SettingMacsec) + 'static>(this: *mut ffi::NMSettingMacsec, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
514 let f: &F = &*(f as *const F);
515 f(&from_glib_borrow(this))
516 }
517 unsafe {
518 let f: Box_<F> = Box_::new(f);
519 connect_raw(self.as_ptr() as *mut _, c"notify::send-sci".as_ptr() as *const _,
520 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_send_sci_trampoline::<F> as *const ())), Box_::into_raw(f))
521 }
522 }
523
524 #[cfg(feature = "v1_6")]
525 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
526 #[doc(alias = "validation")]
527 pub fn connect_validation_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
528 unsafe extern "C" fn notify_validation_trampoline<F: Fn(&SettingMacsec) + 'static>(this: *mut ffi::NMSettingMacsec, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
529 let f: &F = &*(f as *const F);
530 f(&from_glib_borrow(this))
531 }
532 unsafe {
533 let f: Box_<F> = Box_::new(f);
534 connect_raw(self.as_ptr() as *mut _, c"notify::validation".as_ptr() as *const _,
535 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_validation_trampoline::<F> as *const ())), Box_::into_raw(f))
536 }
537 }
538}
539
540#[cfg(feature = "v1_6")]
541#[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
542impl Default for SettingMacsec {
543 fn default() -> Self {
544 Self::new()
545 }
546 }
547
548#[must_use = "The builder must be built to be used"]
553pub struct SettingMacsecBuilder {
554 builder: glib::object::ObjectBuilder<'static, SettingMacsec>,
555 }
556
557 impl SettingMacsecBuilder {
558 fn new() -> Self {
559 Self { builder: glib::object::Object::builder() }
560 }
561
562 #[cfg(feature = "v1_6")]
564 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
565 pub fn encrypt(self, encrypt: bool) -> Self {
566 Self { builder: self.builder.property("encrypt", encrypt), }
567 }
568
569 #[cfg(feature = "v1_6")]
572 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
573 pub fn mka_cak(self, mka_cak: impl Into<glib::GString>) -> Self {
574 Self { builder: self.builder.property("mka-cak", mka_cak.into()), }
575 }
576
577 #[cfg(feature = "v1_6")]
580 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
581 pub fn mka_cak_flags(self, mka_cak_flags: SettingSecretFlags) -> Self {
582 Self { builder: self.builder.property("mka-cak-flags", mka_cak_flags), }
583 }
584
585 #[cfg(feature = "v1_6")]
589 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
590 pub fn mka_ckn(self, mka_ckn: impl Into<glib::GString>) -> Self {
591 Self { builder: self.builder.property("mka-ckn", mka_ckn.into()), }
592 }
593
594 #[cfg(feature = "v1_6")]
597 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
598 pub fn mode(self, mode: i32) -> Self {
599 Self { builder: self.builder.property("mode", mode), }
600 }
601
602 #[cfg(feature = "v1_46")]
614 #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
615 pub fn offload(self, offload: i32) -> Self {
616 Self { builder: self.builder.property("offload", offload), }
617 }
618
619 #[cfg(feature = "v1_6")]
624 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
625 pub fn parent(self, parent: impl Into<glib::GString>) -> Self {
626 Self { builder: self.builder.property("parent", parent.into()), }
627 }
628
629 #[cfg(feature = "v1_6")]
631 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
632 pub fn port(self, port: i32) -> Self {
633 Self { builder: self.builder.property("port", port), }
634 }
635
636 #[cfg(feature = "v1_12")]
639 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
640 pub fn send_sci(self, send_sci: bool) -> Self {
641 Self { builder: self.builder.property("send-sci", send_sci), }
642 }
643
644 #[cfg(feature = "v1_6")]
646 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
647 pub fn validation(self, validation: i32) -> Self {
648 Self { builder: self.builder.property("validation", validation), }
649 }
650
651 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
654 pub fn build(self) -> SettingMacsec {
655assert_initialized_main_thread!();
656 self.builder.build() }
657}