[minor] API change for Task::new

This commit is contained in:
daladim 2021-04-11 19:58:42 +02:00
parent 18e2d0a96a
commit 9d2d83e06f
4 changed files with 47 additions and 38 deletions

View file

@ -7,6 +7,7 @@ use serde::{Deserialize, Serialize};
use url::Url;
use crate::resource::Resource;
use crate::calendar::CalendarId;
@ -95,11 +96,10 @@ pub struct ItemId {
content: Url,
}
impl ItemId{
/// Generate a random ItemId. This should only be useful in tests
pub fn random() -> Self {
/// Generate a random ItemId.
pub fn random(parent_calendar: &CalendarId) -> Self {
let random = uuid::Uuid::new_v4().to_hyphenated().to_string();
let s = format!("https://server.com/{}", random);
let u = s.parse().unwrap();
let u = parent_calendar.join(&random).unwrap(/* this cannot panic since we've just created a string that is a valid URL */);
Self { content:u }
}