Skip to main content

Module ffi

Module ffi 

Source
Expand description

The C ABI layer: the implementation behind include/lmflow/flow.h.

Conventions:

  • Every exported function is wrapped in catch_unwind — letting a Rust panic cross an FFI boundary is undefined behaviour.
  • On failure the thread-local lmflow_last_error is set, so the caller can obtain a readable reason.
  • Structs that cross the boundary are #[repr(C)], with the layout pinned from both sides by tests/abi_layout.rs and cpp/abi_assert.cc.
  • Every exported function null-checks its pointers and returns an error code or a default value rather than crashing.

On missing_safety_doc: the functions here are consumed by C callers, whose safety contract — pointer validity, ownership transfer, lifetimes — is authoritatively defined by the comments in include/lmflow/flow.h, which is the documentation C and C++ users actually read. Restating it here in Rust # Safety form would only create two descriptions that drift apart, so the lint is waived for the whole module.

Structs§

GraphSlot
lmflow_graph_new 先返回一个空槽,init_from_yaml 才真正建图。
InputHandle
The object behind a graph input-port handle; its lifetime follows the graph.
KernelRunnerHandle
LMFlowBuffer
LMFlowContext
LMFlowContract
LMFlowGraph
LMFlowInput
LMFlowInputQueueStats
LMFlowKernelRunner
LMFlowKernelVTable
LMFlowNodeStats
LMFlowPacket
LMFlowPoller

Constants§

ABI_VERSION
BUF_FLAG_READONLY
DEVICE_CPU
INVALID_ID
LMFLOW_DOT_COMPACT
LMFLOW_DOT_DIAGNOSTICS
LMFLOW_DOT_TOPOLOGY
LMFLOW_POLLER_BLOCK
LMFLOW_POLLER_DROP_NEWEST
LMFLOW_POLLER_DROP_OLDEST
LMFLOW_POLLER_LATEST

Functions§

borrow_packet
借用形态:不增加引用计数,调用方不得 drop。
lmflow_abi_version
lmflow_contract_input_id⚠
lmflow_contract_input_index⚠
lmflow_contract_input_name⚠
lmflow_contract_input_set_any⚠
lmflow_contract_input_set_type⚠
lmflow_contract_num_inputs⚠
lmflow_contract_num_outputs⚠
lmflow_contract_output_id⚠
lmflow_contract_output_index⚠
lmflow_contract_output_name⚠
lmflow_contract_output_set_any⚠
lmflow_contract_output_set_type⚠
lmflow_contract_require_side_packet⚠
lmflow_contract_set_error⚠
lmflow_ctx_close_reason⚠
lmflow_ctx_counter_add⚠
lmflow_ctx_emit⚠
lmflow_ctx_forward⚠
lmflow_ctx_has_option⚠
lmflow_ctx_has_side_packet⚠
lmflow_ctx_input⚠
lmflow_ctx_input_at⚠
lmflow_ctx_input_count⚠
lmflow_ctx_input_id⚠
lmflow_ctx_input_index⚠
lmflow_ctx_input_is_done⚠
lmflow_ctx_input_is_empty⚠
lmflow_ctx_input_name⚠
lmflow_ctx_input_payload⚠
lmflow_ctx_input_timestamp⚠
lmflow_ctx_kernel_name⚠
lmflow_ctx_log⚠
lmflow_ctx_node_name⚠
lmflow_ctx_num_inputs⚠
lmflow_ctx_num_outputs⚠
lmflow_ctx_option_bool⚠
lmflow_ctx_option_count⚠
lmflow_ctx_option_f64⚠
lmflow_ctx_option_f64_array⚠
lmflow_ctx_option_i64⚠
lmflow_ctx_option_i64_array⚠
lmflow_ctx_option_str⚠
lmflow_ctx_option_str_array⚠
lmflow_ctx_options_json⚠
lmflow_ctx_output_id⚠
lmflow_ctx_output_index⚠
lmflow_ctx_output_name⚠
lmflow_ctx_require_option_bool⚠
lmflow_ctx_require_option_f64⚠
lmflow_ctx_require_option_i64⚠
lmflow_ctx_require_option_str⚠
lmflow_ctx_set_error⚠
lmflow_ctx_set_next_ts_bound⚠
lmflow_ctx_side_packet⚠
lmflow_ctx_source_done⚠
lmflow_ctx_source_yield⚠
lmflow_ctx_take_input⚠
lmflow_dtype_size
lmflow_graph_add_packet⚠
lmflow_graph_add_poller⚠
lmflow_graph_add_poller_bounded⚠
lmflow_graph_add_poller_ex⚠
lmflow_graph_cancel⚠
lmflow_graph_close_all_inputs⚠
lmflow_graph_close_input⚠
lmflow_graph_counter_count⚠
lmflow_graph_counter_name⚠
lmflow_graph_counter_value⚠
lmflow_graph_dropped_count⚠
lmflow_graph_dump⚠
lmflow_graph_free⚠
lmflow_graph_new 先返回一个空槽,init_from_yaml 才真正建图。
lmflow_graph_init_from_yaml⚠
lmflow_graph_init_from_yaml_file⚠
lmflow_graph_input⚠
lmflow_graph_input_port_name⚠
lmflow_graph_input_queue_stats⚠
lmflow_graph_last_error⚠
lmflow_graph_new
lmflow_graph_node_input_port_name⚠
lmflow_graph_node_name⚠
lmflow_graph_node_num_input_ports⚠
lmflow_graph_node_stats⚠
lmflow_graph_num_input_ports⚠
lmflow_graph_num_nodes⚠
lmflow_graph_num_output_ports⚠
lmflow_graph_observe⚠
lmflow_graph_observe_ex⚠
lmflow_graph_output_port_name⚠
lmflow_graph_pause⚠
lmflow_graph_pump_step⚠
lmflow_graph_pump_steps⚠
lmflow_graph_queue_depth⚠
lmflow_graph_reset⚠
复位已结束的图,使其可再次 start,保留已 open 的算子实例(见 flow.h)。 图须处于 Terminated 且静止,否则返回 LMFLOW_ERR_STATE。
lmflow_graph_resume⚠
lmflow_graph_set_side_packet⚠
lmflow_graph_set_wakeup_callback⚠
lmflow_graph_start⚠
lmflow_graph_state⚠
lmflow_graph_to_chrome_trace⚠
导出当前 trace 环内容为 Chrome Trace Event Format 的 JSON(chrome://tracing / perfetto 可直接打开)。需在建图时设 trace_capacity > 0;未开启时返回合法的空 trace。返回值同 dump:线程局部缓冲,下次在本线程调用即失效,调用方不得 free(需要就先拷走)。
lmflow_graph_to_dot_view⚠
显式选择 Graphviz DOT 的详细程度。返回值同 dump:线程局部缓冲,调用方不得 free。
lmflow_graph_total_queued⚠
lmflow_graph_total_queued_bytes⚠
lmflow_graph_wait_done⚠
lmflow_graph_wait_done_timeout⚠
lmflow_graph_wait_until_idle⚠
lmflow_graph_wait_until_idle_timeout⚠
lmflow_input_close⚠
lmflow_input_free⚠
lmflow_input_send⚠
lmflow_input_try_send⚠
lmflow_kernel_runner_add_input⚠
lmflow_kernel_runner_close⚠
lmflow_kernel_runner_free⚠
lmflow_kernel_runner_new⚠
lmflow_kernel_runner_process⚠
lmflow_kernel_runner_set_options_json⚠
lmflow_kernel_runner_set_side_packet⚠
lmflow_kernel_runner_start⚠
lmflow_kernel_runner_try_next⚠
lmflow_last_error
lmflow_packet_adopt_buffer⚠
lmflow_packet_as_bool⚠
lmflow_packet_as_buffer⚠
lmflow_packet_as_bytes⚠
lmflow_packet_as_f64⚠
lmflow_packet_as_i64⚠
lmflow_packet_as_str⚠
lmflow_packet_clone⚠
lmflow_packet_debug_string⚠
lmflow_packet_drop⚠
lmflow_packet_from_bool
lmflow_packet_from_buffer⚠
lmflow_packet_from_bytes⚠
lmflow_packet_from_f64
lmflow_packet_from_i64
lmflow_packet_from_str⚠
lmflow_packet_has_metadata⚠
lmflow_packet_make_mutable_buffer⚠
lmflow_packet_make_mutable_bytes⚠
lmflow_packet_metadata_bool⚠
lmflow_packet_metadata_count⚠
lmflow_packet_metadata_f64⚠
lmflow_packet_metadata_i64⚠
lmflow_packet_metadata_key_at⚠
lmflow_packet_metadata_str⚠
lmflow_packet_new_buffer⚠
lmflow_packet_new_buffer_uninit⚠
lmflow_packet_remove_metadata⚠
lmflow_packet_set_metadata_bool⚠
lmflow_packet_set_metadata_f64⚠
lmflow_packet_set_metadata_i64⚠
lmflow_packet_set_metadata_str⚠
lmflow_poller_dropped_count⚠
lmflow_poller_free⚠
lmflow_poller_next_status⚠
lmflow_poller_next_timeout⚠
lmflow_poller_try_next_status⚠
lmflow_register_kernel⚠
lmflow_register_kernel_with_language⚠
lmflow_register_type_descriptor⚠
lmflow_set_log_callback
lmflow_type_align
lmflow_type_id⚠
lmflow_type_name
lmflow_type_size
own_packet
移交形态:把一份引用交给调用方,调用方须 emit/send 或 lmflow_packet_drop。
take_packet⚠
接管一个跨界包(消耗调用方的那份所有权)。