pub struct OnvifServer { /* private fields */ }Expand description
A built, configured ONVIF server handle.
Phase 1 stores all builder fields for Phase 2 to use when actually binding a port and starting the soap-server. No network activity occurs in Phase 1.
Fields are intentionally pub(crate) to prevent consumers from bypassing the
builder API or accessing credentials directly. Use the provided accessor methods
for fields that consumers legitimately need.
Implementations§
Source§impl OnvifServer
impl OnvifServer
Sourcepub fn advertised_host(&self) -> &str
pub fn advertised_host(&self) -> &str
Returns the advertised host used in XAddrs for WS-Discovery and capabilities.
Sourcepub fn discovery_uuid(&self) -> Uuid
pub fn discovery_uuid(&self) -> Uuid
Returns the WS-Discovery EndpointReference UUID for this device.
ONVIF conformance (F-7) requires this to be identical across all discovery
cycles, which it is for the lifetime of the server. Set it explicitly via
OnvifServerBuilder::discovery_uuid for an identity that also survives
restarts; otherwise a random UUID-v4 is generated once at builder creation.
Sourcepub fn builder() -> OnvifServerBuilder
pub fn builder() -> OnvifServerBuilder
Create a new builder with default settings.
Defaults: port 8080, GetSystemDateAndTime pre-registered as an auth bypass
operation (per ONVIF spec — clock sync must work without credentials).
Sourcepub fn into_router(self) -> Result<Router, RunError>
pub fn into_router(self) -> Result<Router, RunError>
Build the merged axum Router for all registered services (device + any registered
media/ptz/imaging/events), WITHOUT binding a port or starting the WS-Discovery UDP task.
Used by run() and by in-process harnesses/tests (axum_test).
Sourcepub async fn run(self) -> Result<(), RunError>
pub async fn run(self) -> Result<(), RunError>
Bind the configured port and start serving SOAP requests.
This method does not return until the server is shut down.
Requires a tokio async runtime (#[tokio::main] or tokio::runtime::Runtime).
§Auth behaviour
If the builder was configured with .auth(username, password), WS-Security
UsernameToken authentication is enforced on all non-bypassed operations.
If .auth() was NOT called, the server runs unauthenticated — all
operations are accessible without credentials.
§Service optionality
Only device_service is required (checked at OnvifServerBuilder::build time).
Media, PTZ, Imaging, and Events services are optional; their routes are only
mounted and their capabilities only advertised when they are registered.
§Errors
Returns RunError::Startup if device_service is somehow absent at run time.
Returns RunError::Io if the TCP listener fails to bind or serve.