Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Abel Shields committed Aug 14, 2024
1 parent 7d91ca5 commit bbbd99e
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 48 deletions.
20 changes: 10 additions & 10 deletions src/adaptive_card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::collections::HashMap;
/// Adaptive Card structure for message attachment
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
pub struct AdaptiveCard {
/// Must be "AdaptiveCard"
/// Must be "`AdaptiveCard`"
#[serde(rename = "type")]
pub card_type: String,
/// Schema version that this card requires. If a client is lower than this version, the fallbackText will be rendered.
Expand Down Expand Up @@ -148,11 +148,11 @@ pub enum CardElement {
spacing: Option<Spacing>,
},

/// ColumnSet divides a region into Columns, allowing elements to sit side-by-side.
/// `ColumnSet` divides a region into Columns, allowing elements to sit side-by-side.
ColumnSet {
/// The array of Columns to divide the region into.
columns: Vec<Column>,
/// An Action that will be invoked when the ColumnSet is tapped or selected.
/// An Action that will be invoked when the `ColumnSet` is tapped or selected.
#[serde(rename = "selectAction", skip_serializing_if = "Option::is_none")]
select_action: Option<Action>,
/// A unique identifier associated with the item.
Expand All @@ -166,7 +166,7 @@ pub enum CardElement {
spacing: Option<Spacing>,
},

/// The FactSet element displays a series of facts (i.e. name/value pairs) in a tabular form.
/// The `FactSet` element displays a series of facts (i.e. name/value pairs) in a tabular form.
FactSet {
/// The array of Fact‘s.
facts: Vec<Fact>,
Expand All @@ -184,7 +184,7 @@ pub enum CardElement {
spacing: Option<Spacing>,
},

/// The ImageSet displays a collection of Images similar to a gallery.
/// The `ImageSet` displays a collection of Images similar to a gallery.
ImageSet {
/// The array of Image elements to show.
images: Vec<CardElement>,
Expand Down Expand Up @@ -212,7 +212,7 @@ pub enum CardElement {
/// If true, allow text to wrap. Otherwise, text is clipped.
#[serde(skip_serializing_if = "Option::is_none")]
wrap: Option<bool>,
/// Controls the color of TextBlock elements.
/// Controls the color of `TextBlock` elements.
#[serde(skip_serializing_if = "Option::is_none")]
color: Option<Color>,
/// Controls the horizontal text alignment.
Expand All @@ -233,7 +233,7 @@ pub enum CardElement {
/// Controls size of text.
#[serde(skip_serializing_if = "Option::is_none")]
size: Option<Size>,
/// Controls the weight of TextBlock elements.
/// Controls the weight of `TextBlock` elements.
#[serde(skip_serializing_if = "Option::is_none")]
weight: Option<Weight>,
/// Specifies the height of the element.
Expand Down Expand Up @@ -1055,7 +1055,7 @@ pub enum HorizontalAlignment {
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[serde(tag = "type")]
pub enum Action {
/// Gathers input fields, merges with optional data field, and sends an event to the client. It is up to the client to determine how this data is processed. For example: With BotFramework bots, the client would send an activity through the messaging medium to the bot.
/// Gathers input fields, merges with optional data field, and sends an event to the client. It is up to the client to determine how this data is processed. For example: With `BotFramework` bots, the client would send an activity through the messaging medium to the bot.
#[serde(rename = "Action.Submit")]
Submit {
/// Initial data that input fields will be combined with. These are essentially ‘hidden’ properties.
Expand All @@ -1080,7 +1080,7 @@ pub enum Action {
#[serde(skip_serializing_if = "Option::is_none")]
style: Option<ActionStyle>,
},
/// Defines an AdaptiveCard which is shown to the user when the button or link is clicked.
/// Defines an `AdaptiveCard` which is shown to the user when the button or link is clicked.
#[serde(rename = "Action.ShowCard")]
ShowCard {
/// The Adaptive Card to show.
Expand Down Expand Up @@ -1112,6 +1112,6 @@ pub enum ActionStyle {
pub struct Choice {
/// Text to display.
pub title: String,
/// The raw value for the choice. **NOTE:** do not use a , in the value, since a ChoiceSet with isMultiSelect set to true returns a comma-delimited string of choice values.
/// The raw value for the choice. **NOTE:** do not use a , in the value, since a `ChoiceSet` with isMultiSelect set to true returns a comma-delimited string of choice values.
pub value: String,
}
50 changes: 25 additions & 25 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pub struct Webex {
pub struct WebexEventStream {
ws_stream: WStream,
timeout: Duration,
/// Signifies if WebStream is Open
/// Signifies if `WebStream` is Open
pub is_open: bool,
}

Expand Down Expand Up @@ -158,9 +158,7 @@ impl WebexEventStream {
return Err(msg.unwrap_err().to_string().into());
}
Err(e) => {
return Err(
Error::Tungstenite(e, "Error getting next_result".into()).into()
)
return Err(Error::Tungstenite(e, "Error getting next_result".into()))
}
},
},
Expand Down Expand Up @@ -191,7 +189,7 @@ impl WebexEventStream {
TMessage::Close(t) => {
debug!("close: {:?}", t);
self.is_open = false;
Err(Error::Closed("Web Socket Closed".to_string()).into())
Err(Error::Closed("Web Socket Closed".to_string()))
}
TMessage::Pong(_) => {
debug!("Pong!");
Expand Down Expand Up @@ -232,9 +230,10 @@ impl WebexEventStream {
None => Err("Websocket closed".to_string().into()),
}
}
Err(e) => {
Err(Error::Tungstenite(e, "failed to send authentication".to_string()).into())
}
Err(e) => Err(Error::Tungstenite(
e,
"failed to send authentication".to_string(),
)),
}
}
}
Expand Down Expand Up @@ -408,11 +407,9 @@ impl RestClient {
http_method, prefix, rest_method_trimmed
);
debug!("Retry-After: {:?}", retry_after);
Err(Error::Limited(resp.status(), retry_after).into())
}
status if !status.is_success() => {
Err(Error::StatusText(resp.status(), reply).into())
Err(Error::Limited(resp.status(), retry_after))
}
status if !status.is_success() => Err(Error::StatusText(resp.status(), reply)),
_ => Ok(reply),
}
}
Expand Down Expand Up @@ -512,7 +509,10 @@ impl Webex {
}
Err(e) => {
warn!("Failed to connect to {:?}: {:?}", url, e);
Err(Error::Tungstenite(e, "Failed to connect to ws_url".to_string()).into())
Err(Error::Tungstenite(
e,
"Failed to connect to ws_url".to_string(),
))
}
}
}
Expand Down Expand Up @@ -555,7 +555,7 @@ impl Webex {
}
if let Ok(Some(result)) = MERCURY_CACHE
.lock()
.map(|cache| cache.get(&self.id).map(Clone::clone))
.map(|cache| cache.get(&self.id).cloned())
{
trace!("Found mercury URL in cache!");
return result.map_err(|()| None);
Expand Down Expand Up @@ -680,15 +680,15 @@ impl Webex {
///
/// # Arguments
/// * `message`: [`MessageOut`] - the message to send, including one of `room_id`,
/// `to_person_id` or `to_person_email`.
/// `to_person_id` or `to_person_email`.
///
/// # Errors
/// Types of errors returned:
/// * [`Error::Limited`] - returned on HTTP 423/429 with an optional Retry-After.
/// * [`Error::Status`] | [`Error::StatusText`] - returned when the request results in a non-200 code.
/// * [`Error::Json`] - returned when your input object cannot be serialized, or the return
/// value cannot be deserialised. (If this happens, this is a library bug and should be
/// reported.)
/// value cannot be deserialised. (If this happens, this is a library bug and should be
/// reported.)
/// * [`Error::UTF8`] - returned when the request returns non-UTF8 code.
pub async fn send_message(&self, message: &MessageOut) -> Result<Message, Error> {
self.client
Expand All @@ -707,14 +707,14 @@ impl Webex {
///
/// # Arguments
/// * `params`: [`MessageEditParams`] - the message to edit, including the message ID and the room ID,
/// as well as the new message text.
/// as well as the new message text.
///
/// # Errors
/// Types of errors returned:
/// * [`Error::Limited`] - returned on HTTP 423/429 with an optional Retry-After.
/// * [`Error::Status`] | [`Error::StatusText`] - returned when the request results in a non-200 code.
/// * [`Error::Json`] - returned when your input object cannot be serialized, or the return
/// value cannot be deserialised. (If this happens, this is a library bug and should be reported).
/// value cannot be deserialised. (If this happens, this is a library bug and should be reported).
pub async fn edit_message(
&self,
message_id: &GlobalId,
Expand All @@ -738,8 +738,8 @@ impl Webex {
/// * [`Error::Limited`] - returned on HTTP 423/429 with an optional Retry-After.
/// * [`Error::Status`] | [`Error::StatusText`] - returned when the request results in a non-200 code.
/// * [`Error::Json`] - returned when your input object cannot be serialized, or the return
/// value cannot be deserialised. (If this happens, this is a library bug and should be
/// reported.)
/// value cannot be deserialised. (If this happens, this is a library bug and should be
/// reported.)
/// * [`Error::UTF8`] - returned when the request returns non-UTF8 code.
pub async fn get<T: Gettable + DeserializeOwned>(&self, id: &GlobalId) -> Result<T, Error> {
let rest_method = format!("{}/{}", T::API_ENDPOINT, id.id());
Expand Down Expand Up @@ -836,11 +836,11 @@ impl From<&Message> for MessageOut {
let mut new_msg = Self::default();

if msg.room_type == Some(RoomType::Group) {
new_msg.room_id = msg.room_id.clone();
} else if let Some(person_id) = &msg.person_id {
new_msg.to_person_id = Some(person_id.clone());
new_msg.room_id.clone_from(&msg.room_id);
} else if let Some(_person_id) = &msg.person_id {
new_msg.to_person_id.clone_from(&msg.person_id);
} else {
new_msg.to_person_email = msg.person_email.clone();
new_msg.to_person_email.clone_from(&msg.person_email);
}

new_msg
Expand Down
25 changes: 12 additions & 13 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,11 +680,11 @@ impl Event {
}

fn target_global_id(activity: &Activity) -> Result<String, error::Error> {
Ok(activity
activity
.target
.clone()
.and_then(|t| t.global_id)
.ok_or(crate::error::Error::Api("Missing target id in activity"))?)
.ok_or(crate::error::Error::Api("Missing target id in activity"))
}

/// Get the UUID of the room the Space created event corresponds to.
Expand Down Expand Up @@ -721,10 +721,9 @@ impl Event {
uuid.replace_range(7..8, "0");
Ok(uuid)
} else {
Err(
crate::error::Error::Api("Space created event uuid could not be not patched")
.into(),
)
Err(crate::error::Error::Api(
"Space created event uuid could not be not patched",
))
}
}
}
Expand All @@ -733,7 +732,7 @@ impl Event {
/// being used for a room ID.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum GlobalIdType {
/// This GlobalId represents the ID of a message
/// This `GlobalId` represents the ID of a message
Message,
/// Corresponds to the ID of a person
Person,
Expand All @@ -743,8 +742,8 @@ pub enum GlobalIdType {
Team,
/// Retrieves a specific attachment
AttachmentAction,
/// This GlobalId represents the ID of something not currently recognised, any API requests
/// with this GlobalId will produce an error.
/// This `GlobalId` represents the ID of something not currently recognised, any API requests
/// with this `GlobalId` will produce an error.
Unknown,
}
impl From<ActivityType> for GlobalIdType {
Expand Down Expand Up @@ -809,14 +808,14 @@ impl GlobalId {
/// * ``type_: GlobalIdType`` - the type of the ID being constructed
/// * ``id: String`` - the ID, either old (UUID) or new (base64 geo-ID)
/// * ``cluster: Option<&str>`` - cluster for geo-ID. Only used if the ID is an old-style UUID.
///
/// Will default to `"us"` if not given and can't be determined from the ID - this should work
/// for most requests.
///
/// # Errors
/// * ``Error::Msg`` if:
/// * the ID type is ``GlobalIdType::Unknown``.
/// * the ID is a base64 geo-ID that does not follow the format
/// ``ciscospark://[cluster]/[type]/[id]``.
/// * the ID is a base64 geo-ID that does not follow the format ``ciscospark://[cluster]/[type]/[id]``.
/// * the ID is a base64 geo-ID and the type does not match the given type.
/// * the ID is a base64 geo-ID and the cluster does not match the given cluster.
/// * the ID is neither a UUID or a base64 geo-id.
Expand Down Expand Up @@ -1054,10 +1053,10 @@ pub struct Person {
///
/// active - active within the last 10 minutes
/// call - the user is in a call
/// DoNotDisturb - the user has manually set their status to "Do Not Disturb"
/// `DoNotDisturb` - the user has manually set their status to "Do Not Disturb"
/// inactive - last activity occurred more than 10 minutes ago
/// meeting - the user is in a meeting
/// OutOfOffice - the user or a Hybrid Calendar service has indicated that they are "Out of Office"
/// `OutOfOffice` - the user or a Hybrid Calendar service has indicated that they are "Out of Office"
/// pending - the user has never logged in; a status cannot be determined
/// presenting - the user is sharing content
/// unknown - the user’s status could not be determined
Expand Down

0 comments on commit bbbd99e

Please sign in to comment.