Enum sysctl::CtlValue

source ·
pub enum CtlValue {
Show 16 variants None, Node(Vec<u8>), Int(i32), String(String), S64(i64), Struct(Vec<u8>), Uint(u32), Long(i64), Ulong(u64), U64(u64), U8(u8), U16(u16), S8(i8), S16(i16), S32(i32), U32(u32),
}
Expand description

An Enum that holds all values returned by sysctl calls. Extract inner value with accessors like as_int().

Example

if let Ok(ctl) = sysctl::Ctl::new("kern.osrevision") {
    if let Ok(r) = ctl.value() {
        if let Some(val) = r.as_int() {
            println!("Value: {}", val);
        }
    }
}

Variants§

§

None

§

Node(Vec<u8>)

§

Int(i32)

§

String(String)

§

S64(i64)

§

Struct(Vec<u8>)

§

Uint(u32)

§

Long(i64)

§

Ulong(u64)

§

U64(u64)

§

U8(u8)

§

U16(u16)

§

S8(i8)

§

S16(i16)

§

S32(i32)

§

U32(u32)

Implementations§

source§

impl CtlValue

source

pub fn is_none(&self) -> bool

Returns true if this is a CtlValue::None, otherwise false

source

pub fn is_node(&self) -> bool

Returns true if this is a CtlValue::Node, otherwise false

source

pub fn as_node_mut(&mut self) -> Option<&mut Vec<u8>>

Optionally returns mutable references to the inner fields if this is a CtlValue::Node, otherwise None

source

pub fn as_node(&self) -> Option<&Vec<u8>>

Optionally returns references to the inner fields if this is a CtlValue::Node, otherwise None

source

pub fn into_node(self) -> Result<Vec<u8>, Self>

Returns the inner fields if this is a CtlValue::Node, otherwise returns back the enum in the Err case of the result

source

pub fn is_int(&self) -> bool

Returns true if this is a CtlValue::Int, otherwise false

source

pub fn as_int_mut(&mut self) -> Option<&mut i32>

Optionally returns mutable references to the inner fields if this is a CtlValue::Int, otherwise None

source

pub fn as_int(&self) -> Option<&i32>

Optionally returns references to the inner fields if this is a CtlValue::Int, otherwise None

source

pub fn into_int(self) -> Result<i32, Self>

Returns the inner fields if this is a CtlValue::Int, otherwise returns back the enum in the Err case of the result

source

pub fn is_string(&self) -> bool

Returns true if this is a CtlValue::String, otherwise false

source

pub fn as_string_mut(&mut self) -> Option<&mut String>

Optionally returns mutable references to the inner fields if this is a CtlValue::String, otherwise None

source

pub fn as_string(&self) -> Option<&String>

Optionally returns references to the inner fields if this is a CtlValue::String, otherwise None

source

pub fn into_string(self) -> Result<String, Self>

Returns the inner fields if this is a CtlValue::String, otherwise returns back the enum in the Err case of the result

source

pub fn is_s64(&self) -> bool

Returns true if this is a CtlValue::S64, otherwise false

source

pub fn as_s64_mut(&mut self) -> Option<&mut i64>

Optionally returns mutable references to the inner fields if this is a CtlValue::S64, otherwise None

source

pub fn as_s64(&self) -> Option<&i64>

Optionally returns references to the inner fields if this is a CtlValue::S64, otherwise None

source

pub fn into_s64(self) -> Result<i64, Self>

Returns the inner fields if this is a CtlValue::S64, otherwise returns back the enum in the Err case of the result

source

pub fn is_struct(&self) -> bool

Returns true if this is a CtlValue::Struct, otherwise false

source

pub fn as_struct_mut(&mut self) -> Option<&mut Vec<u8>>

Optionally returns mutable references to the inner fields if this is a CtlValue::Struct, otherwise None

source

pub fn as_struct(&self) -> Option<&Vec<u8>>

Optionally returns references to the inner fields if this is a CtlValue::Struct, otherwise None

source

pub fn into_struct(self) -> Result<Vec<u8>, Self>

Returns the inner fields if this is a CtlValue::Struct, otherwise returns back the enum in the Err case of the result

source

pub fn is_uint(&self) -> bool

Returns true if this is a CtlValue::Uint, otherwise false

source

pub fn as_uint_mut(&mut self) -> Option<&mut u32>

Optionally returns mutable references to the inner fields if this is a CtlValue::Uint, otherwise None

source

pub fn as_uint(&self) -> Option<&u32>

Optionally returns references to the inner fields if this is a CtlValue::Uint, otherwise None

source

pub fn into_uint(self) -> Result<u32, Self>

Returns the inner fields if this is a CtlValue::Uint, otherwise returns back the enum in the Err case of the result

source

pub fn is_long(&self) -> bool

Returns true if this is a CtlValue::Long, otherwise false

source

pub fn as_long_mut(&mut self) -> Option<&mut i64>

Optionally returns mutable references to the inner fields if this is a CtlValue::Long, otherwise None

source

pub fn as_long(&self) -> Option<&i64>

Optionally returns references to the inner fields if this is a CtlValue::Long, otherwise None

source

pub fn into_long(self) -> Result<i64, Self>

Returns the inner fields if this is a CtlValue::Long, otherwise returns back the enum in the Err case of the result

source

pub fn is_ulong(&self) -> bool

Returns true if this is a CtlValue::Ulong, otherwise false

source

pub fn as_ulong_mut(&mut self) -> Option<&mut u64>

Optionally returns mutable references to the inner fields if this is a CtlValue::Ulong, otherwise None

source

pub fn as_ulong(&self) -> Option<&u64>

Optionally returns references to the inner fields if this is a CtlValue::Ulong, otherwise None

source

pub fn into_ulong(self) -> Result<u64, Self>

Returns the inner fields if this is a CtlValue::Ulong, otherwise returns back the enum in the Err case of the result

source

pub fn is_u64(&self) -> bool

Returns true if this is a CtlValue::U64, otherwise false

source

pub fn as_u64_mut(&mut self) -> Option<&mut u64>

Optionally returns mutable references to the inner fields if this is a CtlValue::U64, otherwise None

source

pub fn as_u64(&self) -> Option<&u64>

Optionally returns references to the inner fields if this is a CtlValue::U64, otherwise None

source

pub fn into_u64(self) -> Result<u64, Self>

Returns the inner fields if this is a CtlValue::U64, otherwise returns back the enum in the Err case of the result

source

pub fn is_u8(&self) -> bool

Returns true if this is a CtlValue::U8, otherwise false

source

pub fn as_u8_mut(&mut self) -> Option<&mut u8>

Optionally returns mutable references to the inner fields if this is a CtlValue::U8, otherwise None

source

pub fn as_u8(&self) -> Option<&u8>

Optionally returns references to the inner fields if this is a CtlValue::U8, otherwise None

source

pub fn into_u8(self) -> Result<u8, Self>

Returns the inner fields if this is a CtlValue::U8, otherwise returns back the enum in the Err case of the result

source

pub fn is_u16(&self) -> bool

Returns true if this is a CtlValue::U16, otherwise false

source

pub fn as_u16_mut(&mut self) -> Option<&mut u16>

Optionally returns mutable references to the inner fields if this is a CtlValue::U16, otherwise None

source

pub fn as_u16(&self) -> Option<&u16>

Optionally returns references to the inner fields if this is a CtlValue::U16, otherwise None

source

pub fn into_u16(self) -> Result<u16, Self>

Returns the inner fields if this is a CtlValue::U16, otherwise returns back the enum in the Err case of the result

source

pub fn is_s8(&self) -> bool

Returns true if this is a CtlValue::S8, otherwise false

source

pub fn as_s8_mut(&mut self) -> Option<&mut i8>

Optionally returns mutable references to the inner fields if this is a CtlValue::S8, otherwise None

source

pub fn as_s8(&self) -> Option<&i8>

Optionally returns references to the inner fields if this is a CtlValue::S8, otherwise None

source

pub fn into_s8(self) -> Result<i8, Self>

Returns the inner fields if this is a CtlValue::S8, otherwise returns back the enum in the Err case of the result

source

pub fn is_s16(&self) -> bool

Returns true if this is a CtlValue::S16, otherwise false

source

pub fn as_s16_mut(&mut self) -> Option<&mut i16>

Optionally returns mutable references to the inner fields if this is a CtlValue::S16, otherwise None

source

pub fn as_s16(&self) -> Option<&i16>

Optionally returns references to the inner fields if this is a CtlValue::S16, otherwise None

source

pub fn into_s16(self) -> Result<i16, Self>

Returns the inner fields if this is a CtlValue::S16, otherwise returns back the enum in the Err case of the result

source

pub fn is_s32(&self) -> bool

Returns true if this is a CtlValue::S32, otherwise false

source

pub fn as_s32_mut(&mut self) -> Option<&mut i32>

Optionally returns mutable references to the inner fields if this is a CtlValue::S32, otherwise None

source

pub fn as_s32(&self) -> Option<&i32>

Optionally returns references to the inner fields if this is a CtlValue::S32, otherwise None

source

pub fn into_s32(self) -> Result<i32, Self>

Returns the inner fields if this is a CtlValue::S32, otherwise returns back the enum in the Err case of the result

source

pub fn is_u32(&self) -> bool

Returns true if this is a CtlValue::U32, otherwise false

source

pub fn as_u32_mut(&mut self) -> Option<&mut u32>

Optionally returns mutable references to the inner fields if this is a CtlValue::U32, otherwise None

source

pub fn as_u32(&self) -> Option<&u32>

Optionally returns references to the inner fields if this is a CtlValue::U32, otherwise None

source

pub fn into_u32(self) -> Result<u32, Self>

Returns the inner fields if this is a CtlValue::U32, otherwise returns back the enum in the Err case of the result

Trait Implementations§

source§

impl Debug for CtlValue

source§

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

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

impl Display for CtlValue

source§

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

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

impl From<&CtlValue> for CtlType

source§

fn from(t: &CtlValue) -> Self

Converts to this type from the input type.
source§

impl From<CtlValue> for CtlType

source§

fn from(t: CtlValue) -> Self

Converts to this type from the input type.
source§

impl PartialEq for CtlValue

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for CtlValue

source§

fn partial_cmp(&self, other: &CtlValue) -> 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl StructuralPartialEq for CtlValue

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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.