Refactor: to_ics to as_ics

This commit is contained in:
Lennart
2023-09-16 14:07:52 +02:00
parent 7edb041eb7
commit 78a5a95aa6
3 changed files with 4 additions and 4 deletions

View File

@@ -60,7 +60,7 @@ impl<C: CalendarStore> Resource for EventResource<C> {
write_string_prop(writer, "getetag", &self.event.get_etag())?; write_string_prop(writer, "getetag", &self.event.get_etag())?;
} }
"calendar-data" => { "calendar-data" => {
write_string_prop(writer, "C:calendar-data", self.event.to_ics())?; write_string_prop(writer, "C:calendar-data", self.event.as_ics())?;
} }
"getcontenttype" => { "getcontenttype" => {
write_string_prop(writer, "getcontenttype", "text/calendar;charset=utf-8")?; write_string_prop(writer, "getcontenttype", "text/calendar;charset=utf-8")?;

View File

@@ -53,7 +53,7 @@ pub async fn get_event<A: CheckAuthentication, C: CalendarStore>(
Ok(HttpResponse::Ok() Ok(HttpResponse::Ok()
.insert_header(("ETag", event.get_etag())) .insert_header(("ETag", event.get_etag()))
.body(event.to_ics().to_string())) .body(event.as_ics().to_string()))
} }
pub async fn put_event<A: CheckAuthentication, C: CalendarStore>( pub async fn put_event<A: CheckAuthentication, C: CalendarStore>(

View File

@@ -19,11 +19,11 @@ impl Event {
pub fn get_etag(&self) -> String { pub fn get_etag(&self) -> String {
let mut hasher = Sha256::new(); let mut hasher = Sha256::new();
hasher.update(&self.uid); hasher.update(&self.uid);
hasher.update(self.to_ics()); hasher.update(self.as_ics());
format!("{:x}", hasher.finalize()) format!("{:x}", hasher.finalize())
} }
pub fn to_ics(&self) -> &str { pub fn as_ics(&self) -> &str {
&self.ics &self.ics
} }
} }