pub struct Disclosure { /* private fields */ }Expand description
The line every outbound message carries (spec 3.5 A-I17, §13 Q6): it names the site’s owner and says an AI agent wrote the message.
One default line, overridable per jurisdiction, never removable: an override must
still name the owner and say “AI”, and every driver’s outbox appends the line to every
message it sends. apply is idempotent, so a draft that already ends
with the line keeps one copy.
§Example
use adk_drivers::Disclosure;
let disclosure = Disclosure::new("Wanjiru's Bakery").unwrap();
let body = disclosure.apply("Your order is ready.");
assert_eq!(body, "Your order is ready.\n\nThis message was written by an AI agent for Wanjiru's Bakery.");
assert_eq!(disclosure.apply(&body), body);
assert!(Disclosure::new("Wanjiru's Bakery").unwrap().with_line("Sent by a bot").is_err());Implementations§
Source§impl Disclosure
impl Disclosure
Sourcepub fn new(owner: impl Into<String>) -> Result<Self>
pub fn new(owner: impl Into<String>) -> Result<Self>
The default line for owner: “This message was written by an AI agent for {owner}.”
§Errors
Returns DriverError::Invalid for an empty owner or one with a line break.
Sourcepub fn with_line(self, line: impl Into<String>) -> Result<Self>
pub fn with_line(self, line: impl Into<String>) -> Result<Self>
Replaces the line, as a jurisdiction’s wording requires.
§Errors
Returns DriverError::Invalid when the line does not name the owner, does not say
“AI”, or spans more than one line: the disclosure can be reworded, never removed.
Sourcepub fn apply(&self, body: &str) -> String
pub fn apply(&self, body: &str) -> String
body ending with the line, after a blank line; unchanged when it already ends
with it.
Sourcepub fn is_present(&self, body: &str) -> bool
pub fn is_present(&self, body: &str) -> bool
Whether body ends with the line.
Trait Implementations§
Source§impl Clone for Disclosure
impl Clone for Disclosure
Source§impl Debug for Disclosure
impl Debug for Disclosure
Source§impl<'de> Deserialize<'de> for Disclosure
impl<'de> Deserialize<'de> for Disclosure
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Disclosure
Source§impl PartialEq for Disclosure
impl PartialEq for Disclosure
Source§impl Serialize for Disclosure
impl Serialize for Disclosure
impl StructuralPartialEq for Disclosure
Auto Trait Implementations§
impl Forget for Disclosure
impl Freeze for Disclosure
impl Move for Disclosure
impl RefUnwindSafe for Disclosure
impl Send for Disclosurewhere
RawVecInner: Send,
impl Sync for Disclosurewhere
RawVecInner: Sync,
impl Unpin for Disclosure
impl UnsafeUnpin for Disclosure
impl UnwindSafe for Disclosurewhere
RawVecInner: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more