From 136f56e2d9a010ea76041ba6b44873491ddef848 Mon Sep 17 00:00:00 2001 From: David Blajda Date: Sun, 16 Dec 2018 01:56:43 +0000 Subject: IntegerId uses custom types to prevent comparison to other Id types --- src/types.rs | 113 +++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 91 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/types.rs b/src/types.rs index ef5c486..f3ba5bd 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,29 +1,52 @@ -use std::convert::{AsRef, Into}; +use std::convert::AsRef; +use std::str::FromStr; use std::sync::Arc; +use std::cmp::{Eq, PartialEq}; +use std::marker::PhantomData; /* Used for Id's that can be interpreted as integers but aren't returned as * an int by Twitch's API. (Maybe to allow a quick switch to a different representation * without breaking the json schema?) */ +pub struct User {} +pub struct Video {} + +pub type UserId = IntegerId; +pub type ChannelId = UserId; +pub type VideoId = IntegerId