pub enum CtlValue {
}
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
impl CtlValue
Sourcepub fn as_node_mut(&mut self) -> Option<&mut Vec<u8>>
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
Sourcepub fn as_node(&self) -> Option<&Vec<u8>>
pub fn as_node(&self) -> Option<&Vec<u8>>
Optionally returns references to the inner fields if this is a CtlValue::Node
, otherwise None
Sourcepub fn into_node(self) -> Result<Vec<u8>, Self>
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
Sourcepub fn as_int_mut(&mut self) -> Option<&mut i32>
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
Sourcepub fn as_int(&self) -> Option<&i32>
pub fn as_int(&self) -> Option<&i32>
Optionally returns references to the inner fields if this is a CtlValue::Int
, otherwise None
Sourcepub fn into_int(self) -> Result<i32, Self>
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
Sourcepub fn as_string_mut(&mut self) -> Option<&mut String>
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
Sourcepub fn as_string(&self) -> Option<&String>
pub fn as_string(&self) -> Option<&String>
Optionally returns references to the inner fields if this is a CtlValue::String
, otherwise None
Sourcepub fn into_string(self) -> Result<String, Self>
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
Sourcepub fn as_s64_mut(&mut self) -> Option<&mut i64>
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
Sourcepub fn as_s64(&self) -> Option<&i64>
pub fn as_s64(&self) -> Option<&i64>
Optionally returns references to the inner fields if this is a CtlValue::S64
, otherwise None
Sourcepub fn into_s64(self) -> Result<i64, Self>
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
Sourcepub fn as_struct_mut(&mut self) -> Option<&mut Vec<u8>>
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
Sourcepub fn as_struct(&self) -> Option<&Vec<u8>>
pub fn as_struct(&self) -> Option<&Vec<u8>>
Optionally returns references to the inner fields if this is a CtlValue::Struct
, otherwise None
Sourcepub fn into_struct(self) -> Result<Vec<u8>, Self>
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
Sourcepub fn as_uint_mut(&mut self) -> Option<&mut u32>
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
Sourcepub fn as_uint(&self) -> Option<&u32>
pub fn as_uint(&self) -> Option<&u32>
Optionally returns references to the inner fields if this is a CtlValue::Uint
, otherwise None
Sourcepub fn into_uint(self) -> Result<u32, Self>
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
Sourcepub fn as_long_mut(&mut self) -> Option<&mut i64>
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
Sourcepub fn as_long(&self) -> Option<&i64>
pub fn as_long(&self) -> Option<&i64>
Optionally returns references to the inner fields if this is a CtlValue::Long
, otherwise None
Sourcepub fn into_long(self) -> Result<i64, Self>
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
Sourcepub fn as_ulong_mut(&mut self) -> Option<&mut u64>
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
Sourcepub fn as_ulong(&self) -> Option<&u64>
pub fn as_ulong(&self) -> Option<&u64>
Optionally returns references to the inner fields if this is a CtlValue::Ulong
, otherwise None
Sourcepub fn into_ulong(self) -> Result<u64, Self>
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
Sourcepub fn as_u64_mut(&mut self) -> Option<&mut u64>
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
Sourcepub fn as_u64(&self) -> Option<&u64>
pub fn as_u64(&self) -> Option<&u64>
Optionally returns references to the inner fields if this is a CtlValue::U64
, otherwise None
Sourcepub fn into_u64(self) -> Result<u64, Self>
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
Sourcepub fn as_u8_mut(&mut self) -> Option<&mut u8>
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
Sourcepub fn as_u8(&self) -> Option<&u8>
pub fn as_u8(&self) -> Option<&u8>
Optionally returns references to the inner fields if this is a CtlValue::U8
, otherwise None
Sourcepub fn into_u8(self) -> Result<u8, Self>
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
Sourcepub fn as_u16_mut(&mut self) -> Option<&mut u16>
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
Sourcepub fn as_u16(&self) -> Option<&u16>
pub fn as_u16(&self) -> Option<&u16>
Optionally returns references to the inner fields if this is a CtlValue::U16
, otherwise None
Sourcepub fn into_u16(self) -> Result<u16, Self>
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
Sourcepub fn as_s8_mut(&mut self) -> Option<&mut i8>
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
Sourcepub fn as_s8(&self) -> Option<&i8>
pub fn as_s8(&self) -> Option<&i8>
Optionally returns references to the inner fields if this is a CtlValue::S8
, otherwise None
Sourcepub fn into_s8(self) -> Result<i8, Self>
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
Sourcepub fn as_s16_mut(&mut self) -> Option<&mut i16>
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
Sourcepub fn as_s16(&self) -> Option<&i16>
pub fn as_s16(&self) -> Option<&i16>
Optionally returns references to the inner fields if this is a CtlValue::S16
, otherwise None
Sourcepub fn into_s16(self) -> Result<i16, Self>
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
Sourcepub fn as_s32_mut(&mut self) -> Option<&mut i32>
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
Sourcepub fn as_s32(&self) -> Option<&i32>
pub fn as_s32(&self) -> Option<&i32>
Optionally returns references to the inner fields if this is a CtlValue::S32
, otherwise None
Sourcepub fn into_s32(self) -> Result<i32, Self>
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
Sourcepub fn as_u32_mut(&mut self) -> Option<&mut u32>
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