pub struct Context { /* private fields */ }Expand description
The kmod context
let ctx = kmod::Context::new().unwrap();Implementations§
Source§impl Context
impl Context
Sourcepub fn new() -> Result<Context>
pub fn new() -> Result<Context>
Create a new kmod context.
let ctx = kmod::Context::new().unwrap();Sourcepub fn new_with_dirname(dirname: &Path) -> Result<Context>
pub fn new_with_dirname(dirname: &Path) -> Result<Context>
Create a new kmod context with given directory to search for kernel modules.
use std::path::Path;
let ctx = kmod::Context::new_with_dirname(&Path::new("/lib/modules/6.0.9")).unwrap();Sourcepub fn modules_loaded(&self) -> Result<ModuleIterator>
pub fn modules_loaded(&self) -> Result<ModuleIterator>
Get an iterator of all loaded modules.
let ctx = kmod::Context::new().unwrap();
for module in ctx.modules_loaded().unwrap() {
// ...
}Sourcepub fn module_new_from_lookup<S: AsRef<OsStr>>(
&self,
alias: S,
) -> Result<ModuleIterator>
pub fn module_new_from_lookup<S: AsRef<OsStr>>( &self, alias: S, ) -> Result<ModuleIterator>
Create a module struct by looking up a name or alias.
use std::ffi::{OsStr, OsString};
let ctx = kmod::Context::new()?;
let module = ctx.module_new_from_lookup(&OsString::from("vfat"))?;Sourcepub fn module_new_from_path<S: AsRef<OsStr>>(
&self,
filename: S,
) -> Result<Module>
pub fn module_new_from_path<S: AsRef<OsStr>>( &self, filename: S, ) -> Result<Module>
Create a module struct by path.
let ctx = kmod::Context::new().unwrap();
let module = ctx.module_new_from_path("foo.ko");Sourcepub fn module_new_from_name(&self, name: &str) -> Result<Module>
pub fn module_new_from_name(&self, name: &str) -> Result<Module>
Create a module struct by name.
let ctx = kmod::Context::new().unwrap();
let module = ctx.module_new_from_name("tun").unwrap();Trait Implementations§
Auto Trait Implementations§
impl !Send for Context
impl !Sync for Context
impl Freeze for Context
impl RefUnwindSafe for Context
impl Unpin for Context
impl UnsafeUnpin for Context
impl UnwindSafe for Context
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more