gadk-platform 0.5.24

Time, UUID, task and environment seams and shared helpers for gadk
Documentation
// Copyright 2026 Chris Olson
// Portions derived from ADK-Go (https://github.com/google/adk-go), Copyright 2026 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use chrono::{DateTime, Utc};

/// A source of the current time that tests can replace.
pub trait TimeProvider: Send + Sync {
    /// Returns the current time.
    fn now(&self) -> DateTime<Utc>;
}

impl<F: Fn() -> DateTime<Utc> + Send + Sync> TimeProvider for F {
    fn now(&self) -> DateTime<Utc> {
        self()
    }
}

/// Default provider: the system wall clock.
pub(crate) struct SystemTime;

impl TimeProvider for SystemTime {
    fn now(&self) -> DateTime<Utc> {
        Utc::now()
    }
}