Skip to main content

OnvifServer

Struct OnvifServer 

Source
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

Source

pub fn port(&self) -> u16

Returns the port this server is configured to listen on.

Source

pub fn advertised_host(&self) -> &str

Returns the advertised host used in XAddrs for WS-Discovery and capabilities.

Source

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.

Source

pub fn username(&self) -> Option<&str>

Returns the configured username, if any.

Source

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).

Source

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).

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more