From 2ebe0436ef96a5f657b5118700e715a11fd8dcf6 Mon Sep 17 00:00:00 2001 From: Erin Power Date: Fri, 1 Jul 2022 06:05:44 +0200 Subject: [PATCH] Add InstanceSettings::builder --- examples/federation/instance.rs | 4 ++-- src/lib.rs | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/examples/federation/instance.rs b/examples/federation/instance.rs index 9c1394d..653fa91 100644 --- a/examples/federation/instance.rs +++ b/examples/federation/instance.rs @@ -11,7 +11,7 @@ use activitypub_federation::{ data::Data, deser::context::WithContext, traits::ApubObject, - InstanceSettingsBuilder, + InstanceSettings, LocalInstance, APUB_JSON_CONTENT_TYPE, }; @@ -39,7 +39,7 @@ pub struct Instance { impl Instance { pub fn new(hostname: String) -> Result { - let settings = InstanceSettingsBuilder::default().debug(true).build()?; + let settings = InstanceSettings::builder().debug(true).build()?; let local_instance = LocalInstance::new(hostname.clone(), Client::default().into(), settings); let local_user = MyUser::new(generate_object_id(&hostname)?, generate_actor_keypair()?); diff --git a/src/lib.rs b/src/lib.rs index 2b6fb3b..b890728 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -49,6 +49,13 @@ pub struct InstanceSettings { verify_url_function: fn(&Url) -> Result<(), &'static str>, } +impl InstanceSettings { + /// Returns a new settings builder. + pub fn builder() -> InstanceSettingsBuilder { + <_>::default() + } +} + impl LocalInstance { pub fn new(domain: String, client: ClientWithMiddleware, settings: InstanceSettings) -> Self { let activity_queue = create_activity_queue(client.clone(), &settings);