_simple_rust_driver_rustc_static/
lib.rsuse fdf_component::{driver_register, Driver, DriverContext, Node, NodeBuilder};
use fidl::endpoints::ClientEnd;
use fidl_fuchsia_driver_framework::NodeMarker;
use tracing::info;
use zx::Status;
#[allow(unused)]
struct SimpleRustDriver {
node: Node,
child_node: ClientEnd<NodeMarker>,
}
driver_register!(SimpleRustDriver);
impl Driver for SimpleRustDriver {
const NAME: &str = "simple_rust_driver";
async fn start(mut context: DriverContext) -> Result<Self, Status> {
info!(concat!(
"SimpleRustDriver::start() was invoked. Use this function to do basic initialization ",
"like taking ownership over the node proxy, creating children, and connecting ",
"to resources in the incoming namespace or serving resources to the ",
"outgoing namespace."
));
info!("Binding node client. Every driver needs to do this for the driver to be considered loaded.");
let node = context.take_node()?;
info!("Creating an owned child node with a property");
let node_args = NodeBuilder::new("simple_child")
.add_property(bind_fuchsia_test::TEST_CHILD, "simple")
.build();
let (child_node, _) = node.add_owned_child(node_args).await?;
Ok(Self { node, child_node })
}
async fn stop(&self) {
info!("SimpleRustDriver::stop() was invoked. Use this function to do any cleanup needed.");
}
}