ipp_proto/
ipp.rs

1//!
2//! Base IPP definitions and tags
3//!
4use std::fmt;
5
6use enum_primitive_derive::Primitive;
7
8/// IPP protocol version
9#[derive(Primitive, Debug, Copy, Clone, PartialEq)]
10pub enum IppVersion {
11    Ipp10 = 0x0100,
12    Ipp11 = 0x0101,
13    Ipp20 = 0x0200,
14    Ipp21 = 0x0201,
15    Ipp22 = 0x0202,
16}
17
18/// IPP operation constants
19#[derive(Primitive, Debug, Copy, Clone, PartialEq)]
20pub enum Operation {
21    PrintJob = 0x0002,
22    PrintUri = 0x0003,
23    ValidateJob = 0x0004,
24    CreateJob = 0x0005,
25    SendDocument = 0x0006,
26    SendUri = 0x0007,
27    CancelJob = 0x0008,
28    GetJobAttributes = 0x0009,
29    GetJobs = 0x000A,
30    GetPrinterAttributes = 0x000B,
31    HoldJob = 0x000C,
32    ReleaseJob = 0x000D,
33    RestartJob = 0x000E,
34    PausePrinter = 0x0010,
35    ResumePrinter = 0x0011,
36    PurgeJobs = 0x0012,
37
38    CupsGetDefault = 0x4001,
39    CupsGetPrinters = 0x4002,
40    CupsAddModifyPrinter = 0x4003,
41    CupsDeletePrinter = 0x4004,
42    CupsGetClasses = 0x4005,
43    CupsAddModifyClass = 0x4006,
44    CupsDeleteClass = 0x4007,
45    CupsAcceptJobs = 0x4008,
46    CupsRejectJobs = 0x4009,
47    CupsSetDefault = 0x400A,
48    CupsGetDevices = 0x400B,
49    CupsGetPPDs = 0x400C,
50    CupsMoveJob = 0x400D,
51    CupsAuthenticateJob = 0x400E,
52    CupsGetPPD = 0x400F,
53    CupsGetDocument = 0x4027,
54    CupsCreateLocalPrinter = 0x4028,
55}
56
57/// printer-state constants
58#[derive(Primitive, Debug, Copy, Clone, PartialEq)]
59pub enum PrinterState {
60    Idle = 3,
61    Processing = 4,
62    Stopped = 5,
63}
64
65/// paper orientation constants
66#[derive(Primitive, Debug, Copy, Clone, PartialEq)]
67pub enum Orientation {
68    Portrait = 3,
69    Landscape = 4,
70    ReverseLandscape = 5,
71    ReversePortrait = 6,
72}
73
74/// print-quality constants
75#[derive(Primitive, Debug, Copy, Clone, PartialEq)]
76pub enum PrintQuality {
77    Draft = 3,
78    Normal = 4,
79    High = 5,
80}
81
82/// finishings constants
83#[derive(Primitive, Debug, Copy, Clone, PartialEq)]
84pub enum Finishings {
85    None = 3,
86    Staple = 4,
87    Punch = 5,
88    Cover = 6,
89    Bind = 7,
90    SaddleStitch = 8,
91    EdgeStitch = 9,
92}
93
94/// job-state constants
95#[derive(Primitive, Debug, Copy, Clone, PartialEq)]
96pub enum JobState {
97    Pending = 3,
98    PendingHeld = 4,
99    Processing = 5,
100    ProcessingStopped = 6,
101    Canceled = 7,
102    Aborted = 8,
103    Completed = 9,
104}
105
106/// group delimiter tags
107#[derive(Primitive, Debug, Copy, Clone, PartialEq, Hash, Eq)]
108pub enum DelimiterTag {
109    OperationAttributes = 0x01,
110    JobAttributes = 0x02,
111    EndOfAttributes = 0x03,
112    PrinterAttributes = 0x04,
113    UnsupportedAttributes = 0x05,
114}
115
116/// IPP value tags
117#[derive(Primitive, Debug, Copy, Clone, PartialEq)]
118pub enum ValueTag {
119    Unsupported = 0x10,
120    Unknown = 0x12,
121    NoValue = 0x13,
122    Integer = 0x21,
123    Boolean = 0x22,
124    Enum = 0x23,
125    OctetStringUnspecified = 0x30,
126    DateTime = 0x31,
127    Resolution = 0x32,
128    RangeOfInteger = 0x33,
129    BegCollection = 0x34,
130    TextWithLanguage = 0x35,
131    NameWithLanguage = 0x36,
132    EndCollection = 0x37,
133    TextWithoutLanguage = 0x41,
134    NameWithoutLanguage = 0x42,
135    Keyword = 0x44,
136    Uri = 0x45,
137    UriScheme = 0x46,
138    Charset = 0x47,
139    NaturalLanguage = 0x48,
140    MimeMediaType = 0x49,
141    MemberAttrName = 0x4a,
142}
143
144/// IPP status codes
145#[derive(Primitive, Debug, Copy, Clone, PartialEq)]
146pub enum StatusCode {
147    SuccessfulOK = 0x0000,
148    SuccessfulOKIgnoredOrSubstitutedAttributes = 0x0001,
149    SuccessfulOKConflictingAttributes = 0x0002,
150    ClientErrorBadRequest = 0x0400,
151    ClientErrorForbidden = 0x0401,
152    ClientErrorNotAuthenticated = 0x0402,
153    ClientErrorNotAuthorized = 0x0403,
154    ClientErrorNotPossible = 0x0404,
155    ClientErrorTimeout = 0x0405,
156    ClientErrorNotFound = 0x0406,
157    ClientErrorGone = 0x0407,
158    ClientErrorRequestEntityTooLong = 0x0408,
159    ClientErrorRequestValueTooLong = 0x0409,
160    ClientErrorDocumentFormatNotSupported = 0x040A,
161    ClientErrorAttributesOrValuesNotSupported = 0x040B,
162    ClientErrorUriSchemeNotSupported = 0x040C,
163    ClientErrorCharsetNotSupported = 0x040D,
164    ClientErrorConflictingAttributes = 0x040E,
165    ClientErrorCompressionNotSupported = 0x040F,
166    ClientErrorCompressionError = 0x0410,
167    ClientErrorDocumentFormatError = 0x0411,
168    ClientErrorDocumentAccessError = 0x0412,
169    ServerErrorInternalError = 0x0500,
170    ServerErrorOperationNotSupported = 0x0501,
171    ServerErrorServiceUnavailable = 0x0502,
172    ServerErrorVersionNotSupported = 0x0503,
173    ServerErrorDeviceError = 0x0504,
174    ServerErrorTemporaryError = 0x0505,
175    ServerErrorNotAcceptingJobs = 0x0506,
176    ServerErrorBusy = 0x0507,
177    ServerErrorJobCanceled = 0x0508,
178    ServerErrorMultipleDocumentJobsNotSupported = 0x0509,
179}
180
181impl fmt::Display for StatusCode {
182    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
183        match self {
184            StatusCode::SuccessfulOK => write!(f, "No error"),
185            StatusCode::SuccessfulOKIgnoredOrSubstitutedAttributes => write!(f, "Ignored or substituted attributes"),
186            StatusCode::SuccessfulOKConflictingAttributes => write!(f, "Conflicting attributes"),
187            StatusCode::ClientErrorBadRequest => write!(f, "Bad request"),
188            StatusCode::ClientErrorForbidden => write!(f, "Forbidden"),
189            StatusCode::ClientErrorNotAuthenticated => write!(f, "Not authenticated"),
190            StatusCode::ClientErrorNotAuthorized => write!(f, "Not authorized"),
191            StatusCode::ClientErrorNotPossible => write!(f, "Not possible"),
192            StatusCode::ClientErrorTimeout => write!(f, "Timeout"),
193            StatusCode::ClientErrorNotFound => write!(f, "Not found"),
194            StatusCode::ClientErrorGone => write!(f, "Gone"),
195            StatusCode::ClientErrorRequestEntityTooLong => write!(f, "Entity too long"),
196            StatusCode::ClientErrorRequestValueTooLong => write!(f, "Request value too long"),
197            StatusCode::ClientErrorDocumentFormatNotSupported => write!(f, "Document format not supported"),
198            StatusCode::ClientErrorAttributesOrValuesNotSupported => write!(f, "Attributes or values not supported"),
199            StatusCode::ClientErrorUriSchemeNotSupported => write!(f, "Uri scheme not supported"),
200            StatusCode::ClientErrorCharsetNotSupported => write!(f, "Charset not supported"),
201            StatusCode::ClientErrorConflictingAttributes => write!(f, "Conflicting attributes"),
202            StatusCode::ClientErrorCompressionNotSupported => write!(f, "Compression not supported"),
203            StatusCode::ClientErrorCompressionError => write!(f, "Compression error"),
204            StatusCode::ClientErrorDocumentFormatError => write!(f, "Document format error"),
205            StatusCode::ClientErrorDocumentAccessError => write!(f, "Document access error"),
206            StatusCode::ServerErrorInternalError => write!(f, "Internal error"),
207            StatusCode::ServerErrorOperationNotSupported => write!(f, "Operation not supported"),
208            StatusCode::ServerErrorServiceUnavailable => write!(f, "Service unavailable"),
209            StatusCode::ServerErrorVersionNotSupported => write!(f, "Version not supported"),
210            StatusCode::ServerErrorDeviceError => write!(f, "Device error"),
211            StatusCode::ServerErrorTemporaryError => write!(f, "Temporary error"),
212            StatusCode::ServerErrorNotAcceptingJobs => write!(f, "Not accepting jobs"),
213            StatusCode::ServerErrorBusy => write!(f, "Busy"),
214            StatusCode::ServerErrorJobCanceled => write!(f, "Job canceled"),
215            StatusCode::ServerErrorMultipleDocumentJobsNotSupported => {
216                write!(f, "Multiple document jobs not supported")
217            }
218        }
219    }
220}